Libraries and settings

1. Import and format carbon chemistry data

Seasonality

  • Winter: Jan-Mar
  • Spring: Apr-Jun
  • Summer: Jul-Sep
  • Fall: Oct-Dec
  • Wet: May - October
  • Dry: November - April

2. Check data available

2.1 Locations (all samples)

Figure Supp: Map of the sites where individual samples were collected

Notes: * Check location of individual SiteIDs

2.2 Average GPS point location

Flag samples with coordinates that seem off from the permanent station

# Coordinates<-select(FLK.data, "CTDID", "Latitude", "Longitude", "SiteID")
# Coordinates<-join(Coordinates, WS.GPS.Sites, 
#                  type = "left", by="SiteID")
# Coordinates$Lat_diff <- abs(Coordinates$Latitude-Coordinates$Lat)
# Coordinates$Lon_diff <- abs(Coordinates$Longitude-Coordinates$Lon)
# Check.coordinates1 <- Coordinates[(Coordinates$Lat_diff>0.02), ]
# Check.coordinates2 <- Coordinates[(Coordinates$Lon_diff>0.02), ]
# Check.coordinates <- rbind(Check.coordinates1, Check.coordinates2)
# Check.coordinates <- unique(Check.coordinates)
# #write.csv(Check.coordinates, "FLK_results/2_WrongGPS_points.csv", row.names=F)

- Figure 1: Stations

Figure 1: Location of the permanent sampling stations along the Florida Reef Tract. The black boxes delimitate the biogeographical regions. The color of the stations represents their position along the shelf.

2.3 Number of samples

By zone and location

Sub_region Inshore Mid channel Offshore Oceanic
BB 84 76 83
UK 107 71 111 37
MK 129 129 130 83
LK 138 138 171 87

By year and sub_region

Samples collected each year
Sub_region 2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021
BB 4 14 3 6 30 36 30 35 24 24 37
UK 7 19 3 8 45 51 42 45 30 31 45
MK 15 51 9 11 55 66 55 56 44 44 65
LK 18 61 9 11 58 72 60 76 53 46 70

By climatological season and region

Samples collected in each season
Sub_region Fall Spring Summer Winter
LK 149 133 129 123
MK 133 120 121 97
UK 88 82 84 72
BB 68 60 63 52

By Month-year

Samples collected by year-month
2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021 Months
38 38 19 6 35 January
16 22 38 February
24 2 38 35 33 March
24 38 16 35 37 April
38 16 28 May
20 24 38 38 35 8 June
37 38 18 36 25 July
28 20 38 35 10 August
38 38 36 September
28 38 18 38 36 October
37 35 38 November
25 36 37 37 35 December

By Season-year

Samples collected by year-month
2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021 Season
24 16 24 76 73 52 6 35 38 Winter
20 48 76 38 38 67 35 73 Spring
28 75 76 38 38 72 35 35 Summer
53 36 37 35 38 55 38 75 71 Fall

By Month-region

Samples collected by month-location
Sub_region Zone Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
BB Inshore 7 4 7 9 4 8 10 5 6 8 6 10
BB Mid channel 7 3 6 9 4 5 10 5 6 7 6 8
BB Offshore 7 4 7 9 4 8 10 5 6 8 6 9
UK Inshore 10 4 9 13 6 8 13 8 7 9 9 11
UK Mid channel 7 2 7 6 3 9 9 3 6 6 5 8
UK Offshore 12 3 9 11 5 12 14 6 9 11 8 11
UK Oceanic 3 2 4 3 1 5 4 2 3 4 2 4
MK Inshore 10 6 9 12 8 15 13 11 9 13 9 14
MK Mid channel 9 7 11 12 8 13 13 11 9 13 9 14
MK Offshore 10 6 11 13 7 13 13 11 9 13 9 15
MK Oceanic 6 5 7 7 4 8 8 8 6 8 6 10
LK Inshore 11 8 12 12 7 16 9 15 9 15 9 15
LK Mid channel 12 9 12 12 7 15 10 13 9 15 9 15
LK Offshore 18 7 13 14 10 18 13 18 12 19 12 17
LK Oceanic 7 6 8 8 4 10 5 10 6 9 5 9

Per station during all sampling time

Samples collected in SiteIDs
2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021 SiteID Sub_region Zone
2 6 1 1 5 6 5 6 4 4 6 1 BB Inshore
2 6 1 1 5 6 5 6 4 4 6 3 BB Offshore
1 4 1 5 6 5 4 2 3 4 4 UK Inshore
1 4 1 1 5 6 5 4 2 3 4 5 UK Inshore
2 2 1 1 5 5 4 4 3 3 4 5.5 UK Mid channel
2 4 1 5 5 4 4 3 3 5 6 UK Offshore
1 5 1 1 5 5 4 4 3 3 5 6.5 UK Oceanic
2 5 1 1 5 6 5 5 4 4 5 10 MK Inshore
1 4 1 1 5 6 5 4 4 4 6 13 MK Inshore
2 6 1 5 6 5 6 4 4 6 7 MK Inshore
2 4 1 1 5 6 5 5 4 4 6 11 MK Mid channel
1 3 1 1 5 6 5 5 4 4 6 14 MK Mid channel
2 5 1 1 5 6 5 6 4 4 6 8 MK Mid channel
1 5 1 1 5 6 5 6 4 4 6 12 MK Offshore
2 6 1 5 6 5 6 4 4 6 9 MK Offshore
2 6 1 1 5 6 5 4 4 4 6 9.5 MK Oceanic
2 6 1 1 5 6 5 6 4 4 5 16 LK Inshore
2 6 1 5 6 5 6 4 4 6 19 LK Inshore
2 6 1 1 5 6 5 7 5 4 6 24 LK Inshore
2 6 1 1 5 6 5 7 4 4 5 17 LK Mid channel
2 5 1 1 5 6 5 6 4 4 6 20 LK Mid channel
1 6 1 1 5 6 5 7 5 4 6 23 LK Mid channel
2 6 1 1 5 6 5 7 4 4 6 18 LK Offshore
1 5 1 5 6 5 5 4 4 6 21LK LK Offshore
1 3 1 1 5 6 5 7 5 4 6 22 LK Offshore
2 6 1 1 4 6 5 5 4 3 6 21.5 LK Oceanic
1 6 1 1 4 6 5 6 5 3 6 22.5 LK Oceanic
2 1 1 5 6 5 6 4 4 6 2 BB Mid channel
4 1 1 5 6 5 5 4 4 6 15 MK Offshore
3 1 1 5 6 5 4 4 4 6 15.5 MK Oceanic
1 5 6 5 6 4 4 7 EK_IN BB Inshore
1 5 6 5 5 4 4 6 EK_MID BB Mid channel
1 5 6 5 6 4 4 6 EK_OFF BB Offshore
1 5 6 5 6 4 4 5 UK_IN UK Inshore
1 5 6 5 6 4 4 6 UK_MID UK Mid channel
1 5 6 5 6 4 4 6 UK_OFF UK Offshore
5 6 5 7 5 4 6 MR UK Offshore
5 6 5 7 5 4 6 WS LK Offshore

Remove extreme events?

# Label and filter extreme events
  FLK.data$Extreme<-as.factor(FLK.data$Extreme)
  summary(FLK.data$Extreme)
##      ColdMortality HighOmega_NoReason             Low_pH         LowSalinty 
##                 24                 28                110                 28 
##             Normal 
##               1384
  FLK.data_filtered<-FLK.data[FLK.data$Extreme=="Normal",]

3. TA and DIC salinity normalization

Salinity standardizations

  1. Uses salinity Bottle first, if not available, uses salinity from CTD
#MeanSalinity<-mean(FLK.data[FLK.data$Zone=="Oceanic",]$BestSalinity)
MeanSalinity<-mean(FLK.data$BestSalinity)
sdSalinity<-sd(FLK.data$BestSalinity)

Sal<-paste("Mean salinity = ", round(MeanSalinity, digits=3),
           "(", round(sdSalinity, digits=3), "sd)")
Sal
## [1] "Mean salinity =  35.992 ( 0.839 sd)"
TA_Sal<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (BestSalinity, TA_umol_kg, fill=Season),
             alpha=0.5, shape=21, size=1)+
  geom_smooth(aes(BestSalinity, TA_umol_kg),
              linetype=2, method = "lm", color="black")

ggExtra::ggMarginal(
  p = TA_Sal,
  type = 'boxplot',
  margins = 'both',
  size = 5,
  colour = 'black',
  fill = 'gray'
)

TA_Sal + facet_wrap(~Zone)

TA_Sal+ facet_grid(Zone~Season)
#TA_Sal+ facet_grid(Zone~Precipitation)

DIC_Sal<- ggplot(FLK.data) + MyTheme+
  geom_point(aes (BestSalinity, DIC_umol_kg, fill=Season),
             alpha=0.5, shape=21, size=1)+
  geom_smooth(aes(BestSalinity, DIC_umol_kg),
              linetype=2, method = "lm", color="black")

ggExtra::ggMarginal(
  p = DIC_Sal,
  type = 'boxplot',
  margins = 'both',
  size = 5,
  colour = 'black',
  fill = 'gray'
)

DIC_Sal + facet_wrap(~Zone)

DIC_Sal+ facet_grid(Zone~Season)

  1. Calculate TA intercepts

Note: Use Model II Linear regressions!

“For Model II regressions, neither X nor Y is an INDEPENDENT variable but both are assumed to be DEPENDENT on some other parameter which is often unknown. Neither are”controlled”, both are measured, and both include some error. We do not seek an equation of how Y varies in response to a change in X, but rather we look for how they both co-vary in time or space in response to some other variable or process.”

  • Use ordinary least squares (OLS)?

All data

## 
## Model II regression
## 
## Call: lmodel2(formula = TA_umol_kg ~ BestSalinity, data =
## FLK.data_filtered)
## 
## n = 1381   r = -0.2393467   r-square = 0.05728686 
## Parametric P-values:   2-tailed = 1.917474e-19    1-tailed = 9.587369e-20 
## Angle between the two OLS regression lines = 2.607785 degrees
## 
## Regression results
##   Method Intercept      Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS  3109.940  -20.69533       -87.23361                NA
## 2     MA 15397.963 -361.21227       -89.84138                NA
## 3    SMA  5483.361  -86.46588       -89.33739                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS       2949.866        3270.013  -25.13021   -16.26045
## 2     MA      13097.622       18953.084 -459.72925  -297.46686
## 3    SMA       5327.424        5647.501  -91.01442   -82.14466
## 
## Eigenvalues: 4200.394 0.529631 
## 
## H statistic used for computing C.I. of MA: 3.519553e-07

Oceanic

## 
## Model II regression
## 
## Call: lmodel2(formula = TA_umol_kg ~ BestSalinity, data =
## FLK.data_filtered[FLK.data_filtered$Zone == "Oceanic", ])
## 
## n = 178   r = 0.3189466   r-square = 0.101727 
## Parametric P-values:   2-tailed = 1.430211e-05    1-tailed = 7.151053e-06 
## Angle between the two OLS regression lines = 7.041072 degrees
## 
## Regression results
##   Method Intercept     Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS 2118.7059  7.258729        82.15601                NA
## 2     MA -186.4667 71.231288        89.19569                NA
## 3    SMA 1560.1927 22.758442        87.48406                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS       2003.070       2234.3417   4.049985    10.46747
## 2     MA      -2219.804        600.4083  49.394133   127.65994
## 3    SMA       1436.459       1667.7051  19.774788    26.19228
## 
## Eigenvalues: 147.9711 0.2565248 
## 
## H statistic used for computing C.I. of MA: 3.849783e-05

  1. Calculate DIC intercepts

All data

## 
## Model II regression
## 
## Call: lmodel2(formula = DIC_umol_kg ~ BestSalinity, data =
## FLK.data_filtered)
## 
## n = 1373   r = -0.3754391   r-square = 0.1409545 
## Parametric P-values:   2-tailed = 3.349539e-47    1-tailed = 1.67477e-47 
## Angle between the two OLS regression lines = 1.390794 degrees
## 
## Regression results
##   Method Intercept      Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS  3309.515  -35.37868       -88.38093                NA
## 2     MA 11089.152 -250.96938       -89.77170                NA
## 3    SMA  5433.280  -94.23282       -89.39200                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS       3142.504        3476.527  -40.00593   -30.75143
## 2     MA      10041.663       12451.874 -288.73336  -221.94116
## 3    SMA       5270.401        5604.352  -98.97362   -89.71911
## 
## Eigenvalues: 5011.512 0.4848046 
## 
## H statistic used for computing C.I. of MA: 2.715863e-07

Oceanic

## 
## Model II regression
## 
## Call: lmodel2(formula = DIC_umol_kg ~ BestSalinity, data =
## FLK.data_filtered[FLK.data_filtered$Zone == "Oceanic", ])
## 
## n = 176   r = 0.2408428   r-square = 0.05800523 
## Parametric P-values:   2-tailed = 0.001282336    1-tailed = 0.0006411678 
## Angle between the two OLS regression lines = 5.386842 degrees
## 
## Regression results
##   Method  Intercept      Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS  1686.0115   9.983939        84.28028                NA
## 2     MA -4152.7476 172.027010        89.66694                NA
## 3    SMA   552.0712  41.454182        88.61812                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS      1469.0737       1902.9494   3.963929    16.00395
## 2     MA    -13566.0607      -1821.0943 107.316641   433.27467
## 3    SMA       319.4893        753.3171  35.869007    47.90903
## 
## Eigenvalues: 496.057 0.271903 
## 
## H statistic used for computing C.I. of MA: 1.22848e-05

  1. Add TA and DIC endmembers (S=0) to data frame
# 4. Add endmember intercepts

  TA_SO<-subset(TA_coef, term=="(Intercept)")
  TA_SO<-as.data.frame(dplyr::select(TA_SO, c(Region, estimate)))
  names(TA_SO)[2] <- "TA_0"
  
  DIC_SO<-subset(DIC_coef, term=="(Intercept)")
  DIC_SO<-as.data.frame(dplyr::select(DIC_SO, c(Region, estimate)))
  names(DIC_SO)[2] <- "DIC_0"
    
  Intercepts<-join(TA_SO, DIC_SO, by="Region", type="full")
  FLK.data<-join(FLK.data, Intercepts, by="Region", type="left")
  1. Normalize with (1) Friss equation and (2) mean salinity
  # 5. endmember and salinity (mean) normalization
  FLK.data$nTA<-((
    (FLK.data$TA_umol_kg-FLK.data$TA_0)/
    FLK.data$BestSalinity)*MeanSalinity)+FLK.data$TA_0
  
  FLK.data$nDIC<-((
    (FLK.data$DIC_umol_kg-FLK.data$DIC_0)/
    FLK.data$BestSalinity)*MeanSalinity)+FLK.data$DIC_0
  
  # 2. TA and DIC 35 normalization
    FLK.data$n35TA<-(FLK.data$TA_umol_kg/FLK.data$BestSalinity)*MeanSalinity
    FLK.data$n35DIC<-(FLK.data$DIC_umol_kg/FLK.data$BestSalinity)*MeanSalinity
    # FLK.data$n35TA<-(FLK.data$TA_umol_kg/FLK.data$BestSalinity)*35
    # FLK.data$n35DIC<-(FLK.data$DIC_umol_kg/FLK.data$BestSalinity)*35
  
#write.csv(FLK.data, "FLK_results/FLK.data_filtered_normalized.csv", row.names = F)
  1. TA parameters to nTA (S=0)
kable(as.data.frame(TA_coef[,1:8], format = "markdown"), 
      caption = "Table 1: TA parameters for salinity normalization with endmember S=0",
      digits = 3)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table 1: TA parameters for salinity normalization with endmember S=0
Region term estimate std.error statistic p.value r.squared adj.r.squared
FL (Intercept) 2118.706 58.593 36.160 0 0.102 0.097
FL BestSalinity 7.259 1.626 4.464 0 0.102 0.097
#write.csv(TA_coef, "TA_coef.csv")
# Plot 
Normalization_plot<- ggplot(FLK.data) +
  theme_bw() +  
  theme(legend.position="bottom",
          plot.background=element_blank(),
          panel.grid.major.y = element_blank(),
          panel.grid.major.x = element_blank(),
          panel.grid.minor.x = element_blank(),
          panel.grid.minor.y = element_blank(),
          legend.box.background = element_rect(),
          legend.title = element_blank(),
          panel.background =element_rect(fill = NA, 
                                         color = "black"))+
         scale_x_continuous(limits = c(31.5, 39),
                     expand = c(0.05, 0.05),
                     breaks = seq(30, 40, 2),
                     name=expression(paste("Salinity")))
  1. DIC parameters to nDIC (S=0)
kable(as.data.frame(DIC_coef[,1:8], format = "markdown"), 
      caption = "Table 2: DIC parameters for salinity normalization with endmember S0",
      digits = 2) %>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table 2: DIC parameters for salinity normalization with endmember S0
Region term estimate std.error statistic p.value r.squared adj.r.squared
FL (Intercept) 1686.01 109.91 15.34 0 0.06 0.05
FL BestSalinity 9.98 3.05 3.27 0 0.06 0.05
#write.csv(DIC_coef, "DIC_coef.csv")

Figure Supp 1: Overview of linear regressions of total alkalinity (TA, µmol kg−1) and dissolved inorganic carbon (DIC, µmol kg−1) as a function of salinity + Friss normalized values.

  • Original data: Black line and circles
  • Friis normalization S0 end-member: purple line and pointing up triangles
  • Mean salinity normalization: purple line and pointing down triangles

TA vs Friss salinity normalized TA

Figure Supp X: Linear regressions of Friss normalized total alkalinity (nTA, µmol kg−1) as a function of measured Total Alcalinity (TA, µmol kg−1)

DIC vs Friss salinity normalized DIC

Figure Supp X: Linear regressions of Friss normalized Dissolved Inorganc Carbon (nDIC, µmol kg−1) as a function of measured Dissolved Inorganc Carbon (DIC, µmol kg−1)

TA vs Salinity normalized TA

Figure Supp X: Linear regressions of mean salinity normalized total alkalinity (n35TA, µmol kg−1) as a function of measured Total Alcalinity (TA, µmol kg−1)

DIC vs Salinity normalized DIC

Figure Supp X: Linear regressions of mean salinity normalized Dissolved Inorganc Carbon (n35DIC, µmol kg−1) as a function of measured Dissolved Inorganc Carbon (DIC, µmol kg−1)

Differences vs Salinity

Figure Supp X: Linear regressions of (A) TA-n35TA and (B) DIC-nDIC as a function of Salinity

4. Endmember comparissions

FLK.data_filtered<-FLK.data[FLK.data$Extreme=="Normal",]

4.1 TA and DIC relation

No_ocean.data<-FLK.data[FLK.data$Zone!="Oceanic",]

TA_DIC<- ggplot(No_ocean.data, aes (DIC_umol_kg, TA_umol_kg)) +

  scale_y_continuous(#limits = c(1700,2900),
                     #expand = c(0, 0),
                     #breaks = seq(1800, 2800, 100),
                     expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  scale_x_continuous(# limits = c(1600, 2600),
                     # expand = c(0, 0),
                     # breaks = seq(1500,2600,100),
                     expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
  facet_grid(Sub_region~Zone)+ MyTheme+ 
  theme(legend.position = "bottom")+
  #Season_fill+ Season_colour+
  guides(fill=guide_legend(override.aes=list(shape=21)))
TA_DIC_Zone <- ddply (FLK.data[FLK.data$Extreme=="Normal", ], .(Zone),summarise,
                TAmean = mean (TA_umol_kg, na.rm = T), 
                DICmean = mean (DIC_umol_kg, na.rm = T),
                nTAmean = mean (n35TA, na.rm = T), 
                nDICmean = mean (n35DIC, na.rm = T),
                TAsd = sd (TA_umol_kg, na.rm = T), 
                DICsd = sd (DIC_umol_kg, na.rm = T),
                nTAsd = sd (n35TA, na.rm = T), 
                nDIsd = sd (n35DIC, na.rm = T))

TA_DIC_Ocean<-TA_DIC_Zone[TA_DIC_Zone$Zone=="Oceanic", ]

kable(as.data.frame(TA_DIC_Zone, format = "markdown"),
      caption = "Mean TA/DIC by zone") %>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Mean TA/DIC by zone
Zone TAmean DICmean nTAmean nDICmean TAsd DICsd nTAsd nDIsd
Inshore 2339.763 2015.378 2332.157 2009.834 102.84315 113.22345 140.78447 151.31755
Mid channel 2364.838 2032.799 2360.998 2029.781 52.39024 58.11765 79.54278 82.51523
Offshore 2376.329 2043.844 2372.391 2040.360 19.67731 23.76709 37.86066 36.46979
Oceanic 2380.265 2045.754 2378.003 2043.875 12.16314 22.27196 34.34641 33.66538

Note: Use Model II Linear regressions!

“For Model II regressions, neither X nor Y is an INDEPENDENT variable but both are assumed to be DEPENDENT on some other parameter which is often unknown. Neither are”controlled”, both are measured, and both include some error. We do not seek an equation of how Y varies in response to a change in X, but rather we look for how they both co-vary in time or space in response to some other variable or process.”

Zone and region

# Individual LR for each Zone and Sub_region
    
TA_DIC_coef_zone_noExtremes <- No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Sub_region) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info

TA_DIC_coef_zone_noExtremes<-subset(TA_DIC_coef_zone_noExtremes, term!="(Intercept)")
kable(as.data.frame(TA_DIC_coef_zone_noExtremes[,1:8], 
      format = "markdown"),
      caption = "TA vs DIC equations by zone and region without extreme events",
      digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations by zone and region without extreme events
Zone Sub_region term estimate std.error statistic p.value r.squared
Inshore BB DIC_umol_kg 0.67 0.04 15.22 0 0.76
Inshore UK DIC_umol_kg 0.58 0.03 18.50 0 0.78
Inshore MK DIC_umol_kg 0.84 0.03 24.79 0 0.85
Inshore LK DIC_umol_kg 0.86 0.04 20.28 0 0.78
Mid channel BB DIC_umol_kg 0.57 0.06 9.71 0 0.58
Mid channel UK DIC_umol_kg 0.41 0.07 6.04 0 0.37
Mid channel MK DIC_umol_kg 0.83 0.04 21.55 0 0.81
Mid channel LK DIC_umol_kg 0.81 0.04 20.72 0 0.79
Offshore BB DIC_umol_kg 0.58 0.09 6.70 0 0.38
Offshore UK DIC_umol_kg 0.57 0.05 10.84 0 0.55
Offshore MK DIC_umol_kg 0.77 0.04 19.96 0 0.78
Offshore LK DIC_umol_kg 0.57 0.04 13.61 0 0.56
#write.csv(TA_DIC_coef_zone_noExtremes, "FLK_results/Fig_2_TA_DIC_coef_slopes_Subregion.csv", row.names = FALSE)

# Annotations for plots
  coef_zone_noExtremes<-dplyr::select(TA_DIC_coef_zone_noExtremes, 
                               c("Zone", "Sub_region", "estimate", "r.squared"))
  coef_zone_noExtremes$estimate<-round(coef_zone_noExtremes$estimate, digits=2)
  coef_zone_noExtremes$r.squared<-round(coef_zone_noExtremes$r.squared, digits=2)

Type II Linear regression

TA_DIC_coef_zone_noExtII <- No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Sub_region) %>%
                    do({model = lmodel2(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
#TA_DIC_coef_zone_noExtII

TA_DIC_coef_zone_noExtII<-subset(TA_DIC_coef_zone_noExtII, term!="Intercept")
kable(as.data.frame(TA_DIC_coef_zone_noExtII[,1:9], 
      format = "markdown"),
      caption = "TA vs DIC equations without extreme events using type II lm",
      digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations without extreme events using type II lm
Zone Sub_region method term estimate conf.low conf.high p.value r.squared
Inshore BB MA Slope 0.74 0.64 0.84 0.76
Inshore BB OLS Slope 0.67 0.58 0.76 0.76
Inshore BB SMA Slope 0.77 0.68 0.86 0.76
Inshore UK MA Slope 0.62 0.56 0.69 0.78
Inshore UK OLS Slope 0.58 0.52 0.64 0.78
Inshore UK SMA Slope 0.66 0.60 0.72 0.78
Inshore MK MA Slope 0.91 0.84 0.98 0.85
Inshore MK OLS Slope 0.84 0.77 0.91 0.85
Inshore MK SMA Slope 0.91 0.85 0.98 0.85
Inshore LK MA Slope 0.97 0.88 1.06 0.78
Inshore LK OLS Slope 0.86 0.77 0.94 0.78
Inshore LK SMA Slope 0.97 0.89 1.06 0.78
Mid channel BB MA Slope 0.69 0.55 0.84 0.58
Mid channel BB OLS Slope 0.57 0.45 0.69 0.58
Mid channel BB SMA Slope 0.75 0.64 0.87 0.58
Mid channel UK MA Slope 0.54 0.37 0.73 0.37
Mid channel UK OLS Slope 0.41 0.28 0.55 0.37
Mid channel UK SMA Slope 0.68 0.55 0.83 0.37
Mid channel MK MA Slope 0.91 0.83 1.00 0.81
Mid channel MK OLS Slope 0.83 0.75 0.90 0.81
Mid channel MK SMA Slope 0.92 0.85 1.00 0.81
Mid channel LK MA Slope 0.90 0.82 0.99 0.79
Mid channel LK OLS Slope 0.81 0.73 0.88 0.79
Mid channel LK SMA Slope 0.91 0.84 0.99 0.79
Offshore BB MA Slope 0.89 0.65 1.20 0.38
Offshore BB OLS Slope 0.58 0.40 0.75 0.38
Offshore BB SMA Slope 0.93 0.77 1.12 0.38
Offshore UK MA Slope 0.70 0.58 0.84 0.55
Offshore UK OLS Slope 0.57 0.47 0.67 0.55
Offshore UK SMA Slope 0.77 0.67 0.88 0.55
Offshore MK MA Slope 0.86 0.78 0.95 0.78
Offshore MK OLS Slope 0.77 0.70 0.85 0.78
Offshore MK SMA Slope 0.87 0.80 0.95 0.78
Offshore LK MA Slope 0.70 0.60 0.80 0.56
Offshore LK OLS Slope 0.57 0.49 0.65 0.56
Offshore LK SMA Slope 0.76 0.68 0.85 0.56
# Annotations for plots
  TA_DIC_coef_zone_noExtII<-dplyr::select(TA_DIC_coef_zone_noExtII, 
                               c("Zone", "Sub_region","method", "estimate", "r.squared"))
  TA_DIC_coef_zone_noExtII$estimate<-round(TA_DIC_coef_zone_noExtII$estimate, digits=2)
  TA_DIC_coef_zone_noExtII$r.squared<-round(TA_DIC_coef_zone_noExtII$r.squared, digits=2)

4.2 By Precipitation - Removing Extreme events

TA_DIC_Extreme_pre<-TA_DIC + 
  geom_abline(intercept = -1700, slope=2, color="grey")+
  geom_hline (yintercept = TA_DIC_Ocean$TAmean, color="grey")+
  scale_shape_manual(values=c(24, 25, 23, 22, 21))+
  geom_point(data=No_ocean.data, aes (DIC_umol_kg, TA_umol_kg,
                                 fill=Precipitation, shape=Extreme),
                            alpha=0.5, size=1)+
  geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg), 
              method = "lm", colour="black", se=F)+
  
   geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg, colour=Precipitation), 
              method = "lm", se=F, size=0.5)+
  
  geom_text(data = coef_zone_noExtremes, 
            aes(x = TA_DIC_Ocean$DICmean, y = 2070,
                label = paste("Slo =", estimate,  
                              " r.sq=", r.squared)),
            size=2.5)+
  
  # geom_abline(slope = 0, intercept =TA_DIC_Ocean$TAmean, 
  #           linetype=2, colour="gray")+
  # geom_vline(xintercept = TA_DIC_Ocean$DICmean,
  #          linetype=2, colour="gray")+
  geom_point(aes(x=TA_DIC_Ocean$DICmean, y=TA_DIC_Ocean$TAmean),
             size=3, alpha=1, shape=21, fill="black")
#TA_DIC_Extreme_pre

Zone, region and transect

TA_DIC_reef_pre<-TA_DIC_Extreme_pre + 
  facet_grid(Zone~Reference)
#TA_DIC_reef_pre
# Individual LR for each reef
TA_DIC_coef_Reef_noExtremes <- No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
            group_by(Zone, Sub_region, Reference, Precipitation) %>%
            do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
            data.frame(tidy(model), # get coefficient info
            glance(model))})        # get model info

TA_DIC_coef_Reef_noExtremes<-subset(TA_DIC_coef_Reef_noExtremes, term!="(Intercept)")
kable(as.data.frame(TA_DIC_coef_Reef_noExtremes[,1:11],
                      format = "markdown"),
        caption = "TA vs DIC equations by reef without extreme events per trsansec",
        digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations by reef without extreme events per trsansec
Zone Sub_region Reference Precipitation term estimate std.error statistic p.value r.squared adj.r.squared
Inshore BB BB_1 Dry DIC_umol_kg 0.58 0.05 10.57 0.00 0.85 0.85
Inshore BB BB_1 Wet DIC_umol_kg 0.72 0.07 10.43 0.00 0.86 0.86
Inshore BB BB_2 Dry DIC_umol_kg 0.54 0.07 7.89 0.00 0.79 0.77
Inshore BB BB_2 Wet DIC_umol_kg 0.47 0.15 3.15 0.01 0.42 0.37
Inshore UK UK_3 Dry DIC_umol_kg 0.58 0.03 18.79 0.00 0.92 0.91
Inshore UK UK_3 Wet DIC_umol_kg 0.47 0.09 5.16 0.00 0.50 0.48
Inshore UK UK_4 Dry DIC_umol_kg 0.54 0.05 11.46 0.00 0.90 0.89
Inshore UK UK_4 Wet DIC_umol_kg 0.35 0.22 1.59 0.13 0.15 0.09
Inshore MK MK_5 Dry DIC_umol_kg 0.76 0.07 10.67 0.00 0.86 0.86
Inshore MK MK_5 Wet DIC_umol_kg 0.79 0.10 7.75 0.00 0.78 0.77
Inshore MK MK_6 Dry DIC_umol_kg 0.72 0.09 8.38 0.00 0.81 0.80
Inshore MK MK_6 Wet DIC_umol_kg 0.80 0.13 6.25 0.00 0.70 0.68
Inshore MK MK_7 Dry DIC_umol_kg 0.67 0.08 8.84 0.00 0.84 0.83
Inshore MK MK_7 Wet DIC_umol_kg 0.93 0.15 6.18 0.00 0.69 0.67
Inshore LK LK_8 Dry DIC_umol_kg 0.79 0.10 8.00 0.00 0.78 0.77
Inshore LK LK_8 Wet DIC_umol_kg 0.80 0.11 7.18 0.00 0.76 0.75
Inshore LK LK_9 Dry DIC_umol_kg 0.68 0.09 7.62 0.00 0.77 0.76
Inshore LK LK_9 Wet DIC_umol_kg 0.55 0.19 2.85 0.01 0.32 0.28
Inshore LK LK_10 Dry DIC_umol_kg 0.84 0.14 5.87 0.00 0.63 0.61
Inshore LK LK_10 Wet DIC_umol_kg 0.64 0.14 4.74 0.00 0.57 0.54
Mid channel BB BB_1 Dry DIC_umol_kg 0.53 0.08 6.67 0.00 0.72 0.71
Mid channel BB BB_1 Wet DIC_umol_kg 0.60 0.14 4.36 0.00 0.56 0.53
Mid channel BB BB_2 Dry DIC_umol_kg 0.52 0.09 5.54 0.00 0.66 0.64
Mid channel BB BB_2 Wet DIC_umol_kg 0.38 0.29 1.30 0.22 0.12 0.05
Mid channel UK UK_3 Dry DIC_umol_kg 0.36 0.14 2.58 0.02 0.36 0.30
Mid channel UK UK_3 Wet DIC_umol_kg 0.00 0.17 -0.02 0.98 0.00 -0.07
Mid channel UK UK_4 Dry DIC_umol_kg 0.47 0.10 4.47 0.00 0.56 0.53
Mid channel UK UK_4 Wet DIC_umol_kg 0.63 0.25 2.57 0.02 0.32 0.27
Mid channel MK MK_5 Dry DIC_umol_kg 0.47 0.10 4.53 0.00 0.53 0.51
Mid channel MK MK_5 Wet DIC_umol_kg 0.88 0.17 5.18 0.00 0.61 0.59
Mid channel MK MK_6 Dry DIC_umol_kg 0.59 0.09 6.35 0.00 0.70 0.69
Mid channel MK MK_6 Wet DIC_umol_kg 0.83 0.10 8.45 0.00 0.82 0.81
Mid channel MK MK_7 Dry DIC_umol_kg 0.63 0.07 8.50 0.00 0.82 0.81
Mid channel MK MK_7 Wet DIC_umol_kg 1.09 0.12 9.25 0.00 0.84 0.83
Mid channel LK LK_8 Dry DIC_umol_kg 0.56 0.16 3.50 0.00 0.39 0.36
Mid channel LK LK_8 Wet DIC_umol_kg 0.96 0.07 14.05 0.00 0.92 0.92
Mid channel LK LK_9 Dry DIC_umol_kg 0.67 0.10 6.51 0.00 0.70 0.69
Mid channel LK LK_9 Wet DIC_umol_kg 0.92 0.12 7.51 0.00 0.77 0.75
Mid channel LK LK_10 Dry DIC_umol_kg 0.42 0.18 2.37 0.03 0.22 0.18
Mid channel LK LK_10 Wet DIC_umol_kg 0.88 0.13 6.51 0.00 0.73 0.71
Offshore BB BB_1 Dry DIC_umol_kg 0.53 0.11 4.70 0.00 0.54 0.51
Offshore BB BB_1 Wet DIC_umol_kg 0.61 0.22 2.82 0.01 0.32 0.28
Offshore BB BB_2 Dry DIC_umol_kg 0.49 0.15 3.28 0.00 0.40 0.37
Offshore BB BB_2 Wet DIC_umol_kg 0.57 0.31 1.82 0.09 0.19 0.13
Offshore UK UK_3 Dry DIC_umol_kg 0.63 0.10 6.55 0.00 0.60 0.58
Offshore UK UK_3 Wet DIC_umol_kg 0.56 0.15 3.82 0.00 0.32 0.30
Offshore UK UK_4 Dry DIC_umol_kg 0.48 0.09 5.19 0.00 0.63 0.60
Offshore UK UK_4 Wet DIC_umol_kg 0.90 0.13 6.90 0.00 0.77 0.76
Offshore MK MK_5 Dry DIC_umol_kg 0.50 0.10 5.09 0.00 0.59 0.57
Offshore MK MK_5 Wet DIC_umol_kg 0.85 0.07 12.02 0.00 0.89 0.89
Offshore MK MK_6 Dry DIC_umol_kg 0.51 0.10 4.89 0.00 0.56 0.53
Offshore MK MK_6 Wet DIC_umol_kg 1.07 0.11 9.62 0.00 0.86 0.85
Offshore MK MK_7 Dry DIC_umol_kg 0.43 0.09 4.67 0.00 0.58 0.55
Offshore MK MK_7 Wet DIC_umol_kg 0.95 0.10 9.22 0.00 0.84 0.83
Offshore LK LK_8 Dry DIC_umol_kg 0.25 0.08 3.09 0.01 0.35 0.31
Offshore LK LK_8 Wet DIC_umol_kg 0.97 0.11 8.46 0.00 0.80 0.79
Offshore LK LK_9 Dry DIC_umol_kg 0.55 0.09 6.41 0.00 0.73 0.71
Offshore LK LK_9 Wet DIC_umol_kg 0.83 0.12 6.98 0.00 0.75 0.74
Offshore LK LK_10 Dry DIC_umol_kg 0.48 0.10 4.91 0.00 0.41 0.40
Offshore LK LK_10 Wet DIC_umol_kg 0.77 0.13 5.72 0.00 0.50 0.48
#write.csv (TA_DIC_coef_Reef_noExtremes, "FLK_results/Fig_2_TA_DIC_slopes_Reefs.csv", row.names = FALSE)
  
  
TA_DIC_coef_Reef_noExtremes <- 
  No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Region, Sub_region, Transect, Precipitation) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
Slopes_reef<-subset(TA_DIC_coef_Reef_noExtremes, term!="(Intercept)")

Slope_plot<-ggplot(data=Slopes_reef, aes (x =Zone, y =estimate)) +
  MyTheme+
  scale_shape_manual(values=c(24, 25, 23, 22, 21))+
  geom_boxplot(aes(fill=(Precipitation)), alpha=0.5,
               position=position_dodge(width=0.3))+
  geom_point(aes(fill = factor(Precipitation)), 
              position=position_dodge(width=0.3),
             shape = 21, size=0.5)+
  scale_y_continuous(#limits = c(1700,2900),
                     #expand = c(0, 0),
                     #breaks = seq(1800, 2800, 100),
                     expression(paste("TA vs DIC slope")))+
  theme(axis.text.x = element_text(angle = 0, vjust = 0.1),
        legend.position = "bottom")+
  #guides(fill=FALSE)+
  facet_grid(Sub_region~Region)
  # Season_fill+ Season_colour+
  # theme(legend.title = element_blank())
#Slope_plot

Figure S9: TA (µmol kg−1) vs DIC (µmol kg−1) slopes per season and reef

4.3 By Season - Removing Extreme events

TA_DIC_season<-TA_DIC + 
  Season_colour+ Season_fill+
  geom_abline(intercept = -1700, slope=2, color="grey")+
  geom_hline (yintercept = TA_DIC_Ocean$TAmean, color="grey")+
  scale_shape_manual(values=c(24, 25, 23, 22, 21))+
  geom_point(data=No_ocean.data, aes (DIC_umol_kg, TA_umol_kg,
                                 fill=Season, shape=Extreme),
                            alpha=0.5, size=1)+
  geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg), 
              method = "lm", colour="black", se=F)+
  
   geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg, colour=Season), 
              method = "lm", se=F, size=0.5)+
  
  geom_text(data = coef_zone_noExtremes, 
            aes(x = TA_DIC_Ocean$DICmean, y = 2070,
                label = paste("Slo =", estimate,  
                              " r.sq=", r.squared)),
            size=2.5)+

  geom_point(aes(x=TA_DIC_Ocean$DICmean, y=TA_DIC_Ocean$TAmean),
             size=3, alpha=1, shape=21, fill="black")
#TA_DIC_season
# Individual LR for each reef
TA_DIC_coef_Season_noExtremes <- FLK.data[FLK.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Sub_region, Season) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info

TA_DIC_coef_Season_noExtremes<-subset(TA_DIC_coef_Season_noExtremes, term!="(Intercept)")
kable(as.data.frame(TA_DIC_coef_Season_noExtremes[,1:11],
                      format = "markdown"),
        caption = "TA vs DIC equations by season without extreme events",
        digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations by season without extreme events
Zone Sub_region Season term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore BB Winter DIC_umol_kg 0.67 0.10 6.59 0.00 0.74 0.73 23.70
Inshore BB Spring DIC_umol_kg 0.86 0.11 7.52 0.00 0.75 0.74 36.03
Inshore BB Summer DIC_umol_kg 0.54 0.15 3.61 0.00 0.48 0.45 37.42
Inshore BB Fall DIC_umol_kg 0.80 0.09 8.72 0.00 0.80 0.79 22.56
Inshore UK Winter DIC_umol_kg 0.71 0.05 13.83 0.00 0.91 0.90 21.12
Inshore UK Spring DIC_umol_kg 0.58 0.06 8.96 0.00 0.76 0.75 22.93
Inshore UK Summer DIC_umol_kg 0.80 0.27 2.92 0.01 0.28 0.25 42.64
Inshore UK Fall DIC_umol_kg 0.72 0.06 11.23 0.00 0.85 0.84 27.46
Inshore MK Winter DIC_umol_kg 0.92 0.07 13.52 0.00 0.90 0.89 35.42
Inshore MK Spring DIC_umol_kg 0.84 0.10 8.32 0.00 0.68 0.67 41.83
Inshore MK Summer DIC_umol_kg 1.05 0.09 12.00 0.00 0.87 0.86 37.22
Inshore MK Fall DIC_umol_kg 0.82 0.07 11.50 0.00 0.83 0.82 27.51
Inshore LK Winter DIC_umol_kg 0.64 0.12 5.22 0.00 0.51 0.49 44.09
Inshore LK Spring DIC_umol_kg 0.87 0.08 10.52 0.00 0.77 0.76 35.49
Inshore LK Summer DIC_umol_kg 0.80 0.14 5.88 0.00 0.65 0.63 47.50
Inshore LK Fall DIC_umol_kg 1.08 0.06 17.96 0.00 0.91 0.91 25.26
Mid channel BB Winter DIC_umol_kg 0.80 0.12 6.54 0.00 0.75 0.74 9.85
Mid channel BB Spring DIC_umol_kg 0.64 0.08 7.88 0.00 0.80 0.78 11.95
Mid channel BB Summer DIC_umol_kg 0.61 0.36 1.71 0.11 0.17 0.11 21.37
Mid channel BB Fall DIC_umol_kg 0.56 0.11 5.32 0.00 0.63 0.60 11.63
Mid channel UK Winter DIC_umol_kg 0.66 0.09 7.62 0.00 0.82 0.80 13.29
Mid channel UK Spring DIC_umol_kg 0.04 0.14 0.28 0.79 0.00 -0.06 14.59
Mid channel UK Summer DIC_umol_kg 1.09 0.32 3.45 0.00 0.50 0.46 17.14
Mid channel UK Fall DIC_umol_kg 0.57 0.13 4.44 0.00 0.57 0.54 14.12
Mid channel MK Winter DIC_umol_kg 0.72 0.07 10.08 0.00 0.82 0.81 21.50
Mid channel MK Spring DIC_umol_kg 0.97 0.08 11.47 0.00 0.81 0.80 29.81
Mid channel MK Summer DIC_umol_kg 1.25 0.10 12.61 0.00 0.88 0.87 21.92
Mid channel MK Fall DIC_umol_kg 0.63 0.06 10.51 0.00 0.80 0.79 14.44
Mid channel LK Winter DIC_umol_kg 0.73 0.14 5.10 0.00 0.48 0.46 35.75
Mid channel LK Spring DIC_umol_kg 0.74 0.08 9.40 0.00 0.73 0.73 27.01
Mid channel LK Summer DIC_umol_kg 0.97 0.06 15.11 0.00 0.92 0.92 18.73
Mid channel LK Fall DIC_umol_kg 0.82 0.16 4.96 0.00 0.44 0.42 19.50
Offshore BB Winter DIC_umol_kg 0.74 0.12 5.98 0.00 0.70 0.68 8.49
Offshore BB Spring DIC_umol_kg 0.48 0.13 3.63 0.00 0.41 0.38 8.38
Offshore BB Summer DIC_umol_kg 0.84 0.37 2.27 0.04 0.27 0.22 21.24
Offshore BB Fall DIC_umol_kg 0.32 0.11 2.93 0.01 0.32 0.29 8.97
Offshore UK Winter DIC_umol_kg 0.63 0.08 8.01 0.00 0.75 0.74 6.58
Offshore UK Spring DIC_umol_kg 0.48 0.17 2.86 0.01 0.25 0.22 10.70
Offshore UK Summer DIC_umol_kg 0.93 0.14 6.78 0.00 0.70 0.68 9.77
Offshore UK Fall DIC_umol_kg 0.48 0.11 4.36 0.00 0.44 0.42 10.84
Offshore MK Winter DIC_umol_kg 0.62 0.09 6.95 0.00 0.68 0.66 8.56
Offshore MK Spring DIC_umol_kg 0.89 0.07 12.65 0.00 0.84 0.83 13.80
Offshore MK Summer DIC_umol_kg 0.99 0.08 11.80 0.00 0.86 0.86 12.32
Offshore MK Fall DIC_umol_kg 0.43 0.09 5.03 0.00 0.47 0.45 9.97
Offshore LK Winter DIC_umol_kg 0.48 0.09 5.28 0.00 0.47 0.45 10.09
Offshore LK Spring DIC_umol_kg 0.61 0.08 7.90 0.00 0.61 0.60 11.79
Offshore LK Summer DIC_umol_kg 0.89 0.14 6.41 0.00 0.60 0.59 12.52
Offshore LK Fall DIC_umol_kg 0.30 0.08 3.52 0.00 0.24 0.22 7.99
Oceanic UK Winter DIC_umol_kg 0.74 0.10 7.49 0.00 0.90 0.89 4.81
Oceanic UK Spring DIC_umol_kg 0.17 0.21 0.82 0.44 0.09 -0.04 5.84
Oceanic UK Summer DIC_umol_kg 0.86 0.31 2.79 0.05 0.66 0.58 11.68
Oceanic UK Fall DIC_umol_kg 0.33 0.22 1.51 0.18 0.28 0.16 10.94
Oceanic MK Winter DIC_umol_kg 0.14 0.09 1.61 0.13 0.15 0.09 11.35
Oceanic MK Spring DIC_umol_kg -0.16 0.09 -1.74 0.10 0.15 0.10 14.02
Oceanic MK Summer DIC_umol_kg 0.79 0.11 7.49 0.00 0.80 0.79 6.42
Oceanic MK Fall DIC_umol_kg 0.32 0.12 2.60 0.02 0.27 0.23 10.20
Oceanic LK Winter DIC_umol_kg 0.45 0.15 3.02 0.01 0.35 0.31 11.24
Oceanic LK Spring DIC_umol_kg 0.51 0.11 4.73 0.00 0.53 0.50 8.38
Oceanic LK Summer DIC_umol_kg 0.66 0.13 4.94 0.00 0.69 0.66 7.63
Oceanic LK Fall DIC_umol_kg 0.27 0.12 2.18 0.04 0.22 0.17 7.33
#write.csv (TA_DIC_coef_Season_noExtremes, "FLK_results/Fig_5_TA_DIC_slopes_Reefs.csv", row.names = FALSE)
  
  
  TA_DIC_coef_Season_noExtremes <- FLK.data[FLK.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Region, Sub_region, Season, Transect) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
Slopes_season<-subset(TA_DIC_coef_Season_noExtremes, term!="(Intercept)")

Slope_plot<-ggplot(data=Slopes_season, aes (x =Zone, y =estimate)) +
  MyTheme+
  Zone_shapes4+
  geom_boxplot(aes(fill=Season), alpha=0.5,
               position=position_dodge(width=0.3))+
  geom_point(aes(fill = factor(Season)), 
              position=position_dodge(width=0.3),
             shape = 21, size=0.5)+
  scale_y_continuous(#limits = c(1700,2900),
                     #expand = c(0, 0),
                     #breaks = seq(1800, 2800, 100),
                     expression(paste("TA vs DIC slope")))+
  facet_grid(Sub_region~Region)+
  Season_fill+
  Season_colour+
  guides(fill=FALSE)+
  theme(axis.text.x = element_text(angle = 90, vjust = 0.1),
        legend.position = "bottom")
#Slope_plot

Figure 6: TA (µmol kg−1) vs DIC (µmol kg−1) slopes per season and reef

5 Seasonal plots

Data for endmember comparisons

# Reef
  WS.reef<-subset(FLK.data, FLK.data$Zone!="Oceanic")
  WS.reef$Date<-as.Date(WS.reef$Date, "%Y-%m-%d")
  
# Open
  WS.open<-subset(FLK.data_filtered,
                  FLK.data_filtered$Zone=="Oceanic")
  WS.open$Date<-as.Date(WS.open$Date, "%Y-%m-%d")
  #summary(WS.open)
# Mean ocean values by month - year 
  mean_Open_MY<- ddply (WS.open, .(MY, Month),
                            summarise,
                  OTem_my = mean (Temperature_C, na.rm = T),  
                  OSal_my = mean (BestSalinity, na.rm = T), 
                  
                  OTA_my = mean (TA_umol_kg, na.rm = T),
                  OnTA_my = mean (n35TA, na.rm = T),
                  
                  ODIC_my = mean (DIC_umol_kg, na.rm = T),
                  OnDIC_my = mean (n35DIC, na.rm = T),
                  
                  OpCO2_O = mean (pCO2_uatm , na.rm = T),
                  OpH_O = mean (pH_calculated, na.rm = T),
                  OAra_O = mean (Aragonite_Sat_W , na.rm = T)
                  )

# Mean ocean values by month
  mean_OpM <- mean_Open_MY %>%
              group_by(Month) %>%
              summarise(
                  OTem_m = mean (OTem_my, na.rm = T), 
                  OSal_m = mean (OSal_my, na.rm = T), 
                  
                  OTA_m = mean (OTA_my, na.rm = T),
                  OnTA_m = mean (OnTA_my, na.rm = T),
                  
                  OnDIC_m = mean (OnDIC_my, na.rm = T),
                  ODIC_m = mean (ODIC_my, na.rm = T),
                  
                  OpCO2_m = mean (OpCO2_O , na.rm = T),
                  OpH_m = mean (OpH_O, na.rm = T),
                  OAra_m = mean (OAra_O, na.rm = T),
                  n = n()
                  )
   #mean_OpM
  
 # Mean ocean values by year    
  mean_Op<- mean_OpM %>%
            summarise(
                  OTem = mean (OTem_m, na.rm = T), 
                  OSal  = mean (OSal_m, na.rm = T), 
                  
                  OTA = mean (OTA_m, na.rm = T),
                  OnTA = mean (OnTA_m, na.rm = T),
                  
                  OnDIC = mean (OnDIC_m, na.rm = T),
                  ODIC = mean (ODIC_m, na.rm = T),
                  
                  OpCO2 = mean (OpCO2_m, na.rm = T),
                  OpH = mean (OpH_m, na.rm = T),
                  OAra = mean (OAra_m, na.rm = T),
                  n = n()
                  )

5.1 Month raw values

- Months stats

Month_Stats<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region),
                            summarise,
                       
                  Tem_mean = mean (Temperature_C, na.rm = T),
                  Tem_sd = sd (Temperature_C, na.rm = T),
                  #Tem_se = std.error (Temperature_C, na.rm = T),
                  
                  Sal_mean = mean (BestSalinity, na.rm = T),
                  Sal_sd = sd (BestSalinity, na.rm = T),
                  #Sal_se = std.error (BestSalinity, na.rm = T),
                       
                  TA_mean = mean (TA_umol_kg, na.rm = T),
                  TA_sd = sd (TA_umol_kg, na.rm = T),
                  #TA_se = std.error (TA_umol_kg, na.rm = T),
                  
                  nTA_mean = mean (n35TA, na.rm = T),
                  nTA_sd = sd (n35TA, na.rm = T),
                  
                  DIC_mean = mean (DIC_umol_kg, na.rm = T),
                  DIC_sd = sd (DIC_umol_kg, na.rm = T),
                  #DIC_se = std.error (DIC_umol_kg, na.rm = T),
                  
                  nDIC_mean = mean (n35DIC, na.rm = T),
                  nDIC_sd = sd (n35DIC, na.rm = T),
                  
                  pCO2_mean = mean (pCO2_uatm , na.rm = T),
                  pCO2_sd = sd (pCO2_uatm , na.rm = T),
                  #pCO2_se = std.error (pCO2_uatm, na.rm = T),
                  
                  pH_mean = mean (pH_calculated, na.rm = T),
                  pH_sd = sd (pH_calculated, na.rm = T),
                  #pH_se = std.error (pH_calculated, na.rm = T),
                  
                  Ara_mean = mean (Aragonite_Sat_W , na.rm = T),
                  Ara_sd = sd (Aragonite_Sat_W , na.rm = T),
                  #Ara_se = std.error (Aragonite_Sat_W, na.rm = T),
                  n = n())

Month_Stats_2d<-Month_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
Month_Stats_2d
#write.csv(Month_Stats, "FLK_results/Table_S7_Month_Stats.csv", row.names = F)

Temp

Month_Temp<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (Temperature_C, na.rm = T),
                  sd = sd (Temperature_C, na.rm = T))

Month_Temp<-Month_Temp %>% 
 mutate_if(is.numeric, round, digits=2)
Month_Temp$Region<-NULL

Month_Temp<-reshape(Month_Temp, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

Sal

Month_Sal<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (BestSalinity, na.rm = T),
                  sd = sd (BestSalinity, na.rm = T))

Month_Sal<-Month_Sal %>% 
 mutate_if(is.numeric, round, digits=2)
Month_Sal$Region<-NULL

Month_Sal<-reshape(Month_Sal, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

TA

Month_TA<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (TA_umol_kg, na.rm = T),
                  sd = sd (TA_umol_kg, na.rm = T))

Month_TA<-Month_TA %>% 
 mutate_if(is.numeric, round, digits=2)
Month_TA$Region<-NULL

Month_TA<-reshape(Month_TA, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

DIC

Month_DIC<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (DIC_umol_kg, na.rm = T),
                  sd = sd (DIC_umol_kg, na.rm = T))

Month_DIC<-Month_DIC %>% 
 mutate_if(is.numeric, round, digits=2)
Month_DIC$Region<-NULL

Month_DIC<-reshape(Month_DIC, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

pCO2

Month_pCO2<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (pCO2_uatm , na.rm = T),
                  sd = sd (pCO2_uatm , na.rm = T))

Month_pCO2<-Month_pCO2 %>% 
 mutate_if(is.numeric, round, digits=2)
Month_pCO2$Region<-NULL

Month_pCO2<-reshape(Month_pCO2, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

pH

Month_pH<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (pH_calculated, na.rm = T),
                  sd = sd (pH_calculated, na.rm = T))

Month_pH<-Month_pH %>% 
 mutate_if(is.numeric, round, digits=2)
Month_pH$Region<-NULL

Month_pH<-reshape(Month_pH, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

Arag

Month_Ara<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (Aragonite_Sat_W , na.rm = T),
                  sd = sd (Aragonite_Sat_W , na.rm = T))

Month_Ara<-Month_Ara %>% 
 mutate_if(is.numeric, round, digits=2)
Month_Ara$Region<-NULL

Month_Ara<-reshape(Month_Ara, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

all

Month_Stats3<-rbind(Month_Temp, Month_Sal, Month_TA, Month_DIC, 
      Month_pCO2, Month_pH, Month_Ara)

#write.csv(Month_Stats3, "FLK_results/Table_S7_Month_Stats_wide.csv", row.names = F)

Seasonal range

Seasonal_range<-ddply (Month_Stats, .(Zone, Sub_region),
                            summarise,
                  Tem_meany = mean (Tem_mean, na.rm = T),
                  Tem_sdy = sd (Tem_mean, na.rm = T),
                  Tem_max = max (Tem_mean, na.rm = T),
                  Tem_min = min (Tem_mean, na.rm = T),
                  Tem_diff = (max (Tem_mean, na.rm = T) - min (Tem_mean, na.rm = T)),
                  
                  Sal_meany = mean (Sal_mean, na.rm = T),
                  Sal_sdy = sd (Sal_mean, na.rm = T),
                  Sal_max = max (Sal_mean, na.rm = T),
                  Sal_min = min (Sal_mean, na.rm = T),
                  Sal_diff = (max (Sal_mean, na.rm = T) - min (Sal_mean, na.rm = T)),
                  
                  TA_meany = mean (TA_mean, na.rm = T),
                  TA_sdy = sd (TA_mean, na.rm = T), 
                  TA_max = max (TA_mean, na.rm = T),
                  TA_min = min (TA_mean, na.rm = T),
                  TA_diff = (max (TA_mean, na.rm = T) - min (TA_mean, na.rm = T)),
                  
                  DIC_meany = mean (DIC_mean, na.rm = T),
                  DIC_sdy = sd (DIC_mean, na.rm = T), 
                  DIC_max = max (DIC_mean, na.rm = T),
                  DIC_min = min (DIC_mean, na.rm = T),
                  DIC_diff = (max (DIC_mean, na.rm = T) - min (DIC_mean, na.rm = T)),
                  
                  pCO2_meany = mean (pCO2_mean, na.rm = T),
                  pCO2_sdy = sd (pCO2_mean, na.rm = T), 
                  pCO2_max = max (pCO2_mean, na.rm = T),
                  pCO2_min = min (pCO2_mean, na.rm = T),
                  pCO2_dif = (max (pCO2_mean, na.rm = T) - min (pCO2_mean, na.rm = T)),
                  
                  pH_meany = mean (pH_mean, na.rm = T),
                  pH_sdy = sd (pH_mean, na.rm = T), 
                  pH_max = max (pH_mean, na.rm = T),
                  pH_min = min (pH_mean, na.rm = T),
                  pH_diff = (max (pH_mean, na.rm = T) - min (pH_mean, na.rm = T)),
                  
                  Arg_meany = mean (Ara_mean, na.rm = T),
                  Arg_sdy = sd (Ara_mean, na.rm = T),  
                  Ara_max = max (Ara_mean, na.rm = T),
                  Ara_min = min (Ara_mean, na.rm = T),
                  Ara_diff = (max (Ara_mean, na.rm = T) - min (Ara_mean, na.rm = T)),
                  
                  
                  nTA_max = max (nTA_mean, na.rm = T),
                  nTA_min = min (nTA_mean, na.rm = T),
                  nTA_diff = (max (nTA_mean, na.rm = T) - min (nTA_mean, na.rm = T)),
                  
                  nDIC_max = max (nDIC_mean, na.rm = T),
                  nDIC_min = min (nDIC_mean, na.rm = T),
                  nDIC_diff = (max (nDIC_mean, na.rm = T) - min (nDIC_mean, na.rm = T)),
                  
                  n = n())

Seasonal_range<-Seasonal_range %>% 
 mutate_if(is.numeric, round, digits=2)
Seasonal_range
#Seasonal_range$pH_max_diff<-Seasonal_range$pH_max-mean()

#write.csv(Seasonal_range, "FLK_results/Table_S8_Month_mean_range.csv", row.names = F)

- Month Plots

Month_ploth<- ggplot(FLK.data) +
        MyTheme + 
        facet_grid(Sub_region~Zone)+
        scale_shape_manual(values=c(24, 25, 23, 22, 21))+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank() )

Year_ploth<- ggplot(Month_Stats) +
        MyTheme +  
        theme(axis.title.x = element_blank(), axis.text.x=element_text(angle = 10, vjust = 0.5))+
        Season_fill+
        Season_colour+
        facet_grid(Sub_region~Region)
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        #theme(axis.title.x = element_blank() )

Month_Season_plotTA_DIC<- ggplot(FLK.data_filtered[
          FLK.data_filtered$Zone!="Oceanic",]) +
        MyTheme +  
        facet_grid(~Zone)+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        scale_x_continuous(limits = c(1,12),
                     expand = c(0.05, 0.05),
                     breaks = seq(1, 12, 1),
                     name=expression(paste("Month of the year")))+
        theme(#strip.text = element_blank(),
              legend.position = "none",
              axis.title.x = element_blank()
              )

Month_Season_plot<- ggplot(FLK.data_filtered) +
        MyTheme +  
        facet_grid(~Zone)+
        Zone_shapes4+
        #Region_fill+
        #Region_colour+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        scale_x_continuous(limits = c(1,12),
                   expand = c(0.05, 0.05),
                   breaks = seq(1, 12, 1),
                   name=expression(paste("Month of the year")))+
        theme(axis.title.x = element_blank())#,
        #       legend.position = "none")

Year_plot_2<- ggplot(Month_Stats)+
#[Month_Stats$Zone!="Oceanic",]) +
        MyTheme +  
        facet_grid(~Zone)+
        Zone_shapes4+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        #Season_fill+
        #Season_colour+
        theme(#axis.title.x = element_blank()#,
              #axis.text.y=element_blank(),
              legend.position = "bottom"
              )

Year_plot_3<- ggplot(Month_Stats, aes(fill=Sub_region, shape=Zone))+
#[Month_Stats$Zone!="Oceanic",]) +
        MyTheme +  
        Zone_shapes4+
        facet_grid(~Region)+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(#axis.title.x = element_blank()#,
              #axis.text.y=element_blank(),
              legend.position = "right",
              axis.title.x = element_blank(),
              axis.text.x = element_text(angle = 20, vjust = 0.5)
              )

Temperature

Figure Supp 2: Temperature variation by the region and shelf position by (A) month of the year and (B) season.

Temp_exp<- Month_Season_plot+
  geom_abline(slope = 0, intercept = mean_Op$OTem, color="grey")+
    scale_y_continuous(#limits = c(15,40),
                       name=(expression("Temperature"~(degree*C))),
                       breaks = seq(16, 40, 2),  
                       expand = c(0.05, 0.05)) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=Temperature_C, colour=Sub_region),
                span=0.6, alpha=0.2, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=Temperature_C, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=Temperature_C, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))
    
#Temp_exp

Salinity

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   25.36   31.99   34.03   33.87   36.06   39.43

Figure Supp 3: Salinity variation by the region and shelf position by (A) month of the year and (B) season.

Sal_exp<- Month_Season_plot+
  geom_abline(slope = 0, intercept = mean_Op$OSal, color="grey")+
   scale_y_continuous(#limits = c(15,40),
                       name=(expression("Salinity")),
                       breaks = seq(15, 40, 1),  
                       expand = c(0.05, 0.05)) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=BestSalinity, colour=Sub_region),
                span=0.8, alpha=0.2, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=BestSalinity, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=BestSalinity, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))
    
#Sal_exp

TA

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    2214    2609    2730    2721    2851    3052

Figure Supp XX: Total Alkalinity (TA) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 3A

TA_exp<- Month_Season_plot+
   geom_abline(slope = 0, intercept = mean_Op$OTA, color="grey")+
   scale_y_continuous(#limits = c(2100,2500),
                     expand = c(0.05, 0.05),
                     breaks = seq(2100, 2500, 100),
                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  
  # geom_smooth(data=FLK.data, se=F, colour="gray70", alpha=0.5, size=0.5,
  #               aes(x=as.numeric(Month2), y=Temp.adj))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=TA_umol_kg, colour=Sub_region),
                span=0.8, alpha=0.2, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=TA_umol_kg, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=TA_umol_kg, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))
    
#


TA_Y2<- Year_plot_2+
   geom_abline(slope = 0, intercept = mean_Op$OTA, color="grey")+
   scale_y_continuous(#limits = c(2150,2550),
                     expand = c(0.05, 0.05),
                     breaks = seq(2200, 2500, 50),
                    name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  
   stat_summary(aes (x=Sub_region, y=TA_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2)+
   stat_summary(aes (x=Sub_region, y=TA_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)
#TA_Y2

TA_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OTA, color="grey")+
   scale_y_continuous(limits = c(2130,2510),
                     expand = c(0.05, 0.05),
                     breaks = seq(2100, 2500, 100),
                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=TA_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=TA_min,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   # geom_segment(data=Seasonal_range, 
   #              aes(   x = Zone, y = TA_min, 
   #                  xend = Zone, yend = TA_max,
   #                  colour=Sub_region),
   #              #position = position_dodge(width = 0.6), 
   #              alpha=0.3)+
   stat_summary(aes (x=Zone, y=TA_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
   stat_summary(aes (x=Zone, y=TA_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#TA_Y3

Figure 3A: Total Alkalinity (TA) variation by the region and shelf position. Left: monthly mean values, Right: Yearly mean values

DIC

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1791    2133    2238    2230    2342    2516

Figure Supp XX: Disolved Inorganic Carbon (DIC) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 3B

DIC_exp<- Month_Season_plot+
   geom_abline(slope = 0, intercept = mean_Op$ODIC, color="grey")+
   scale_y_continuous(#limits = c(1780,2270),
                     expand = c(0.05, 0.05),
                     breaks = seq(1800, 2800, 100),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
    geom_smooth(aes (x=as.numeric(Month2),
                    y=DIC_umol_kg, colour=Sub_region),
                    span=0.8, alpha=0.2, se=F)+
   
    stat_summary(aes (x=as.numeric(Month2),
                      y=DIC_umol_kg, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width=0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=DIC_umol_kg, fill=Sub_region, shape=Zone),
                size=1,
                fun = "mean", geom = "point",
                position=position_dodge(width=0.3))
#DIC_exp

DIC_Y2<- Year_plot_2+
   geom_abline(slope = 0, intercept = mean_Op$ODIC, color="grey")+
   scale_y_continuous(#limits = c(1700,2900),
                     expand = c(0.05, 0.05),
                     #breaks = seq(1800, 2800, 100),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
    
   stat_summary(aes (x=Sub_region, y=DIC_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)+
   stat_summary(aes (x=Sub_region, y=DIC_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point",
                size=2)
#DIC_Y2

DIC_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$ODIC, color="grey")+
   scale_y_continuous(limits = c(1820,2230),
                     expand = c(0.00, 0.00),
                     breaks = seq(1800, 2800, 100),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=DIC_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=DIC_min,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
  # geom_segment(data=Seasonal_range, 
  #               aes(   x = Zone, y = DIC_min, 
  #                   xend = Zone, yend = DIC_max,
  #                   colour=Sub_region),
  #               #position = position_dodge(width = 0.6), 
  #               alpha=0.3)+
   stat_summary(aes (x=Zone, y=DIC_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=DIC_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#DIC_Y3

Figure 3B: Dissolved Inorganic Carbon (DIC) by the region and shelf position. Left: monthly mean values, Right: Yearly mean values

pCO2

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   496.6   880.6   998.7   989.1  1116.0  1311.3

Figure Supp 6: pCO2 variation by the region and shelf position by (A) month of the year and (B) season.

pCO2_exp<- Month_Season_plot+
   geom_abline(slope = 0, intercept = mean_Op$OpCO2, color="grey")+
     scale_y_continuous(#limits = c(1,5.5),
                       name=expression(paste(pCO[2], " (", mu, " atm)")),
                       breaks = seq(200, 600, 100),
                       expand = c(0.05, 0.05)
                        ) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=pCO2_uatm, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=pCO2_uatm, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
     stat_summary(aes (x=as.numeric(Month2), 
                      y=pCO2_uatm, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))
#pCO2_exp

pCO2_Y2<- Year_plot_2+
  geom_abline(slope = 0, intercept = mean_Op$OpCO2, color="grey")+
  scale_y_continuous(#limits = c(1,5.5),
                       name=expression(paste(pCO[2], 
                                             " (", mu, " atm)")),
                       breaks = seq(200, 600, 50),
                       expand = c(0.05, 0.05)
                        ) +
    
   stat_summary(aes (x=Sub_region, y=pCO2_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)+
  stat_summary(aes (x=Sub_region, y=pCO2_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)
#pCO2_Y2

pH

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   7.953   8.235   8.322   8.315   8.408   8.552

Figure Supp 7: pH variation by the region and shelf position by (A) month of the year and (B) season.

pH_exp<- Month_Season_plot+
    geom_abline(slope = 0, intercept = mean_Op$OpH, color="grey")+
    scale_y_continuous(#limits = c(7.88,8.25),
                       name=(expression (pH)),
                       breaks = seq(0, 9, 0.1),
                       expand = c(0.02, 0)
                        ) +
    
    geom_smooth(aes (x=as.numeric(Month2),
                      y=pH_calculated, colour=Sub_region),
                span=0.8, se=F)+
    
    stat_summary(aes (x=as.numeric(Month2),
                      y=pH_calculated, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
     stat_summary(aes (x=as.numeric(Month2), 
                      y=pH_calculated, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))
#pH_exp

pH_Y2<- Year_plot_2+
  geom_abline(slope = 0, intercept = mean_Op$OpH, color="grey")+
    scale_y_continuous(#limits = c(1,5.5),
                       name=(expression (pH[calculated])),
                       breaks = seq(0, 9, 0.05),
                       expand = c(0.05, 0.05)
                        ) +
    
   stat_summary(aes (x=Sub_region, y=pH_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)+
    stat_summary(aes (x=Sub_region, y=pH_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)
#pH_Y2

pH_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OpH, color="grey")+
   scale_y_continuous(limits = c(7.87,8.22),
                       name=(expression (pH)),
                       breaks = seq(0, 9, 0.1),
                       expand = c(0.02, 0)
                        )+
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=pH_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1, 
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=pH_min, 
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   # geom_segment(data=Seasonal_range, 
   #              aes(   x = Zone, y = pH_min, 
   #                  xend = Zone, yend = pH_max,
   #                  colour=Sub_region),
   #              #position = position_dodge(width = 0.6), 
   #              alpha=0.3)+
   stat_summary(aes (x=Zone, y=pH_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=pH_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#pH_Y3

Figure 3C

Omega

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.715   4.277   4.758   4.719   5.235   6.029

Figure Supp 8: Omega variation by the region and shelf position by (A) month of the year and (B) season.

Figure 3D

Omega_exp<- Month_Season_plot+
    geom_abline(slope = 0, intercept = mean_Op$OAra, color="grey")+
    scale_y_continuous(#limits = c(1,5.5),
                       name=(expression("\n" ~Omega[Ar])),
                       breaks = seq(1, 5, 0.5),
                       expand = c(0.05, 0.05)
                        ) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=Aragonite_Sat_W, colour=Sub_region),
                span=0.8, alpha=0.2, se=F
                #method = lm, formula = y ~ splines::bs(x, 3),
                )+
      stat_summary(aes (x=as.numeric(Month2),
                      y=Aragonite_Sat_W, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=Aragonite_Sat_W, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))

#Omega_exp

Om_Y2<- Year_plot_2+
  geom_abline(slope = 0, intercept = mean_Op$OAra, color="grey")+
  scale_y_continuous(#limits = c(1,5.5),
                       # name=(expression (
                       #   "Aragonite saturation state "(~Omega[Ar]))),
                      name=(expression (
                      ~Omega[Ar])),
                       breaks = seq(1, 5, 0.5),
                       expand = c(0.05, 0.05)
                        ) +
    
  stat_summary(aes (x=Sub_region, y=Ara_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)+
  stat_summary(aes (x=Sub_region, y=Ara_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)
#Om_Y2

Om_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OAra , color="grey")+
  scale_y_continuous(#limits = c(1,5.5),
                       # name=(expression (
                       #   "Aragonite saturation state "(~Omega[Ar]))),
                      name=(expression (
                      ~Omega[Ar])),
                       breaks = seq(1, 5, 0.5),
                       expand = c(0.1, 0.1)
                        ) +
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=Ara_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1, 
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=Ara_min, 
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   # geom_segment(data=Seasonal_range, 
   #              aes(   x = Zone, y = Ara_min, 
   #                  xend = Zone, yend = Ara_max,
   #                  colour=Sub_region),
   #              #position = position_dodge(width = 0.6), 
   #              alpha=0.3)+
   stat_summary(aes (x=Zone, y=Ara_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=Ara_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#Om_Y3

Figure 3C: Aragonite saturation state (omega) by the region and shelf position. Left: monthly mean values, Right: Yearly mean values + SD, maximum monthly mean and minimum monthly mean.

Fig.3: Seasonal monthly plot

No summary

with summary

Fig.3: Seasonal monthly plot supplemental

Figure 3: Monthly seasonal patterns in (A) Total Alkalinity (TA), (B) Dissolved Inorganic Carbon (DIC), and (C) aragonite saturation state (Ωar) in the Florida Reef Tract. The colors represent the biogeographical regions and the vertical panels separate the locations by shelf zone. The points show the (monthly mean values ± 95 CI) and the lines the smoothed curves for the data (method = ‘loess’ and formula ‘y ~ x’, span=0.8). Gray horizontal lines in each panel demarcate the mean values of the parameters in the oceanic samples.

5.2 Season raw values

- Season stats (all data)

  • do not use for further calculations since some months have more data than
  • can be used to compare the aggregated meas ussing MM
Seasonal_Stats<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season),
             summarise,

      Tem_mean = mean (Temperature_C, na.rm = T),
      Tem_sd = sd (Temperature_C, na.rm = T),
    
      Sal_mean = mean (BestSalinity, na.rm = T),
      Sal_sd = sd (BestSalinity, na.rm = T),
    
      TA_mean = mean (TA_umol_kg, na.rm = T),
      TA_sd = sd (TA_umol_kg, na.rm = T),
    
      nTA_mean = mean (n35TA, na.rm = T),
      nTA_sd = sd (n35TA, na.rm = T),
    
      nDIC_mean = mean (n35DIC, na.rm = T),
      nDIC_sd = sd (n35DIC, na.rm = T),
    
      DIC_mean = mean (DIC_umol_kg, na.rm = T),
      DIC_sd = sd (DIC_umol_kg, na.rm = T),
    
      pCO2_mean = mean (pCO2_uatm , na.rm = T),
      pCO2_sd = sd (pCO2_uatm , na.rm = T),
    
      pH_mean = mean (pH_calculated, na.rm = T),
      pH_sd = sd (pH_calculated, na.rm = T),
    
      Ara_mean = mean (Aragonite_Sat_W , na.rm = T),
      Ara_sd = sd (Aragonite_Sat_W , na.rm = T),
       n())

Seasonal_Stats<-Seasonal_Stats %>% 
 mutate_if(is.numeric, round, digits=2)
Seasonal_Stats

- Season stats (monthly mean)

Seasonal_Stats2<- ddply (Month_Stats, .(Zone, Sub_region, Season),
                         summarise,

                  Tem_M = mean (Tem_mean, na.rm = T),
                  #Tem_sd = sd (Tem_mean, na.rm = T),
                  Tem_se = std.error (Tem_mean, na.rm = T),

                  Sal_M = mean (Sal_mean, na.rm = T),
                  #Sal_sd = sd (Sal_mean, na.rm = T),
                  Sal_se = std.error (Sal_mean, na.rm = T),

                  TA_M = mean (TA_mean, na.rm = T),
                  #TA_sd = sd (TA_mean, na.rm = T),
                  TA_se = std.error (TA_mean, na.rm = T),
                  
                  DIC_M = mean (DIC_mean, na.rm = T),
                  #DIC_sd = sd (DIC_mean, na.rm = T),
                  DIC_se = std.error (DIC_mean, na.rm = T),
                  
                  #nTA_M = mean (nTA_mean, na.rm = T),
                  #nTA_sd = sd (nTA_mean, na.rm = T),
                  
                  #nDIC_M = mean (nDIC_mean, na.rm = T),
                  #nDIC_sd = sd (nDIC_mean, na.rm = T),

                  pCO2_M = mean (pCO2_mean , na.rm = T),
                  #pCO2_sd = sd (pCO2_mean , na.rm = T),
                  pCO2_se = std.error (pCO2_mean , na.rm = T),

                  pH_M = mean (pH_mean, na.rm = T),
                  #pH_sd = sd (pH_mean, na.rm = T),
                  pH_se = std.error (pH_mean, na.rm = T),

                  Ara_M = mean (Ara_mean , na.rm = T),
                  #Ara_sd = sd (Ara_mean , na.rm = T),
                  Ara_se = std.error (Ara_mean , na.rm = T),
                  n())

Seasonal_Stats2<-Seasonal_Stats2 %>% 
 mutate_if(is.numeric, round, digits=2)
Seasonal_Stats2
# write.csv(Seasonal_Stats2, "FLK_results/Table_S_Season_A.csv", row.names = F)

Note: SD is NA when calculating it based on monthly meand (n=3 per season)

- Yearly stats (monthly mean)

Yearly_Stats<- ddply (Month_Stats, .(Zone, Sub_region),
                         summarise,

                  Tem_Y = mean (Tem_mean, na.rm = T),
                  Tem_sd = sd (Tem_mean, na.rm = T),

                  Sal_Y = mean (Sal_mean, na.rm = T),
                  Sal_sd = sd (Sal_mean, na.rm = T),

                  TA_Y = mean (TA_mean, na.rm = T),
                  TA_sd = sd (TA_mean, na.rm = T),

                  nTA_Y = mean (nTA_mean, na.rm = T),
                  nTA_sd = sd (nTA_mean, na.rm = T),

                  nDIC_Y = mean (nDIC_mean, na.rm = T),
                  nDIC_sd = sd (nDIC_mean, na.rm = T),

                  DIC_Y = mean (DIC_mean, na.rm = T),
                  DIC_sd = sd (DIC_mean, na.rm = T),

                  pCO2_Y = mean (pCO2_mean , na.rm = T),
                  pCO2_sd = sd (pCO2_mean , na.rm = T),

                  pH_Y = mean (pH_mean, na.rm = T),
                  pH_sd = sd (pH_mean, na.rm = T),

                  Ara_Y = mean (Ara_mean , na.rm = T),
                  Ara_sd = sd (Ara_mean , na.rm = T),
                  n())

Yearly_Stats<-Yearly_Stats %>% 
 mutate_if(is.numeric, round, digits=2)
Yearly_Stats
# write.csv(Yearly_Stats, "FLK_results/Table_1_Year_A.csv", row.names = F)

Note: SD is NA when calculating it based on monthly meand (n=3 per season)

5.3 Delta months values

# 1. Get the oceanic mean values per month-year 

  WS.reef<-join(WS.reef, mean_Open_MY, 
                 type = "left", by=c("MY", "Month"))

# 2. and subtract them from the reef data
  # Delta TA
  WS.reef$dTA_MY<-WS.reef$TA_umol_kg-WS.reef$OTA_my
  # Delta DIC
  WS.reef$dDIC_MY<-WS.reef$DIC_umol_kg-WS.reef$ODIC_my
  # Delta nTA
  WS.reef$dnTA_MY<-WS.reef$n35TA-WS.reef$OnTA_my
  # Delta nDIC
  WS.reef$dnDIC_MY<-WS.reef$n35DIC-WS.reef$OnDIC_my
  # Delta pCO2
  WS.reef$dpCO2_MY<-WS.reef$pCO2_uatm-WS.reef$OpCO2_O
  # Delta pH
  WS.reef$dpH_MY<-WS.reef$pH_calculated-WS.reef$OpH_O
   # Delta Omega
  WS.reef$dOme_MY<-WS.reef$Aragonite_Sat_W-WS.reef$OAra_O
  
 # head(WS.reef)
 #summary(WS.reef$Season, digits=2)

- Delta month stats

dMonth_Stats<- ddply (WS.reef, .(Zone, Sub_region, Month2, Season, Region),
                            summarise,
                  dTA_mean = mean (dTA_MY, na.rm = T),
                  dTA_sd = sd (dTA_MY, na.rm = T),
                  #dTA_se = std.error (dTA_MY, na.rm = T),
                  
                  dnTA_mean = mean (dnTA_MY, na.rm = T),
                  dnTA_sd = sd (dnTA_MY, na.rm = T),
                 
                  dDIC_mean = mean (dDIC_MY, na.rm = T),
                  dDIC_sd = mean (dDIC_MY, na.rm = T),
                  #dDIC_se = std.error (dDIC_MY, na.rm = T),
                  
                  dnDIC_mean = mean (dnDIC_MY, na.rm = T),
                  dnDIC_sd = sd (dnDIC_MY, na.rm = T),
                  
                  dpCO2_mean = mean (dpCO2_MY , na.rm = T),
                  dpCO2_sd = sd (dpCO2_MY , na.rm = T),
                  #dpCO2_se = std.error (dpCO2_MY, na.rm = T),
                  
                  dpH_mean = mean (dpH_MY, na.rm = T),
                  dpH_sd = sd (dpH_MY, na.rm = T),
                  #dPH_se = std.error (dpH_MY, na.rm = T),
                  
                  dAra_mean = mean (dOme_MY , na.rm = T),
                  dAra_sd = sd (dOme_MY , na.rm = T)#,
                  #dAra_se = std.error (dOme_MY, na.rm = T),
                  )

dMonth_Stats<-dMonth_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
dMonth_Stats
#write.csv(dMonth_Stats, "FLK_results/Table_S9_Month_StatsDeltas.csv", row.names = F)

Spring.data<-WS.reef[WS.reef$Season=="Spring", ]
Summer.data<-WS.reef[WS.reef$Season=="Summer", ]
Fall.data<-WS.reef[WS.reef$Season=="Fall", ]
Winter.data<-WS.reef[WS.reef$Season=="Winter", ]

Seasonal range

Seasonal_range_d<-ddply (dMonth_Stats, .(Zone, Sub_region),
                            summarise,

                  
                  dTA_max = max (dTA_mean, na.rm = T),
                  dTA_min = min (dTA_mean, na.rm = T),
                  dTA_diff = (max (dTA_mean, na.rm = T) - min (dTA_mean, na.rm = T)),
                  
                  dDIC_max = max (dDIC_mean, na.rm = T),
                  dDIC_min = min (dDIC_mean, na.rm = T),
                  dDIC_diff = (max (dDIC_mean, na.rm = T) - min (dDIC_mean, na.rm = T)),
                  
                  dpCO2_max = max (dpCO2_mean, na.rm = T),
                  dpCO2_min = min (dpCO2_mean, na.rm = T),
                  dpCO2_dif = (max (dpCO2_mean, na.rm = T) - min (dpCO2_mean, na.rm = T)),
                  
                  dpH_max = max (dpH_mean, na.rm = T),
                  dpH_min = min (dpH_mean, na.rm = T),
                  dpH_diff = (max (dpH_mean, na.rm = T) - min (dpH_mean, na.rm = T)),
                  
                  dAra_max = max (dAra_mean, na.rm = T),
                  dAra_min = min (dAra_mean, na.rm = T),
                  dAra_diff = (max (dAra_mean, na.rm = T) - min (dAra_mean, na.rm = T)),
                  
                  n = n())

Seasonal_range_d<-Seasonal_range_d %>% 
 mutate_if(is.numeric, round, digits=3)
Seasonal_range_d
#write.csv(Seasonal_range_d, "FLK_results/Table_S8_Month_mean_range_d.csv", row.names = F)

- Delta month plots

Delta_plot<- ggplot(WS.reef) +
        MyTheme +  
        facet_grid(Sub_region~Zone)+
        scale_shape_manual(values=c(24, 25, 23, 22, 21))+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank())

DeltaYear_plot<- ggplot(dMonth_Stats) +
        MyTheme +  
        facet_grid(Sub_region~Region)+
        Season_fill+
        Season_colour+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              axis.text.x = element_text(angle = 10,
                                         vjust = 0.5))
        
Delta_plot_month<- ggplot(WS.reef) +
        MyTheme +  
        geom_abline(slope = 0, intercept = 0, color="grey")+
        facet_grid(~Zone)+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        scale_x_continuous(limits = c(1,12),
                     expand = c(0.05, 0.05),
                     breaks = seq(1, 12, 1),
                     name=expression(paste("Month of the year")))+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom")

DeltaYear_plot2<- ggplot(dMonth_Stats) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))

DeltaYear_plot3<- ggplot(dMonth_Stats) +
        MyTheme +  
        Zone_shapes3+
        facet_grid(~Region)+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))

Frequency_plot<- ggplot(data = WS.reef) +
      geom_vline(aes(xintercept = 0), linetype = "dashed")+
      facet_grid(Zone~Sub_region, scales = "free_y")+ MyTheme

dTA

Figure Supp 4: Total Alkalinity (TA) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 4A

DTA_exp<- Delta_plot_month+
   scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.05, 0.05),
                     breaks = seq(-800, 800, 100),
                     name=expression(paste(Delta,
                          "TA  (", mu, "mol ", ~kg^-1, ")")))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=dTA_MY, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=dTA_MY, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=dTA_MY, fill=Sub_region),
                 shape=21, size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))

#DTA_exp

TA_delta_Y2<- DeltaYear_plot2+
    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "TA  (", mu, "mol ", ~kg^-1, ")")))+
    stat_summary(aes (x=Season, y=dTA_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "bar",
                position=position_dodge(width=0.8))+
    stat_summary(aes (x=Season, y=dTA_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.8))
#TA_delta_Y2

dTA_Y3<- DeltaYear_plot3+
   scale_y_continuous(#limits = c(-210,70),
                     expand = c(0.03, 0.03),
                     #breaks = seq(0, 2500, 50),
                     name=expression(paste("")))+
    
   stat_summary(aes (x=Zone, y=dTA_mean,
                     fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=1.5, 
                position=position_dodge(width=0.5))+
  stat_summary(aes (x=Zone, y=dTA_mean, colour=Sub_region),
               fun.data = "mean_cl_boot", 
               geom = "errorbar",  width = 0.2,
               position=position_dodge(width=0.5))+
  facet_grid(~Region)
#dTA_Y3

Figure 4A: Seasonal delta Total Alkalinity (dTA) variation by region and shelf position. Mean values and 95 CI

dDIC

Figure Supp 5: Total Alkalinity (TA) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 4B

dDIC_exp<- Delta_plot_month+
   scale_y_continuous(#limits = c(1700,2900),
                     expand = c(0.05, 0.05),
                     breaks = seq(-800, 800, 100),
                     name=expression(paste(Delta, "DIC  (", mu, "mol ", ~kg^-1, ")")))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=dDIC_MY, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=dDIC_MY, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=dDIC_MY, fill=Sub_region),
                 shape=21, size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))

#dDIC_exp

DIC_delta_Y2<- DeltaYear_plot2+
    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.05, 0.05),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "DIC  (", mu, "mol ", ~kg^-1, ")")))+
    stat_summary(aes (x=Season, y=dDIC_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "bar",
                position=position_dodge(width=0.8))+
    stat_summary(aes (x=Season, y=dDIC_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.8))
  
#DIC_delta_Y2

dDIC_Y3<- DeltaYear_plot3+
   scale_y_continuous(#limits = c(-185,130),
                     expand = c(0.01, 0.01),
                     #breaks = seq(0, 2500, 50),
                     name=expression(paste("")))+
    
   stat_summary(aes (x=Zone, y=dDIC_mean, 
                     fill=Sub_region, shape = Zone), 
                fun.data = "mean_cl_boot", geom = "point", 
                size=1.5,
                position=position_dodge(width=0.5))+
  stat_summary(aes (x=Zone, y=dDIC_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", 
               geom = "errorbar",   width = 0.2,
               position=position_dodge(width=0.5))
#dDIC_Y3

Figure 4B: Seasonal delta Dissolved Inorganic Carbon (dDIC) variation by region and shelf position.

dDIC density

dDIC_freq_All<- Frequency_plot+
  geom_density(aes (dDIC_MY), fill = "lightgray", alpha=0.5) +
  scale_x_continuous(breaks = seq(-300, 300, 100),
                     expression(paste(Delta, "DIC (", mu, "mol ", kg^-1, ")")))
#dDIC_freq_All

dDIC_freq_pre<- Frequency_plot+
  geom_density(aes (dDIC_MY, fill = Precipitation),
               alpha = 0.4) +
  scale_x_continuous(breaks = seq(-300, 300, 100),
                    expression(paste(Delta, "DIC (", mu, "mol ", kg^-1, ")")))
#dDIC_freq_pre

# dDIC_freq_sea<- Frequency_plot+
#   geom_density(aes (dDIC_MY, fill = Season), alpha = 0.4) +
#   scale_x_continuous(breaks = seq(-300, 300, 100),
#                      expression(paste(Delta, "DIC (", mu, "mol ", kg^-1, ")")))
# dDIC_freq_sea

dpCO2

pdCO2_exp<- Delta_plot_month+
   scale_y_continuous(#limits = c(1700,2900),
                     expand = c(0.05, 0.05),
                     #breaks = seq(1800, 2800, 100),
                     name=expression(paste(Delta ~ pCO[2] , " (", mu, "atm)")))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=dpCO2_MY, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=dpCO2_MY, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=dpCO2_MY, fill=Sub_region),
                 shape=21, size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))
#pdCO2_exp

pCO2_delta_Y2<- DeltaYear_plot2+
    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.1, 0.1),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta ~ pCO[2] , " (", mu, "atm)")))+
    stat_summary(aes (x=Season, y=dpCO2_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "bar",
                position=position_dodge(width=0.8))+
    stat_summary(aes (x=Season, y=dpCO2_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.8))
#pCO2_delta_Y2

dPCO2_Y3<- DeltaYear_plot2+
   scale_y_continuous(#limits = c(2150,2550),
                     expand = c(0.01, 0.01),
                     #breaks = seq(0, 2500, 50),
                     name=expression(paste("")))+
    
   stat_summary(aes (x=Sub_region, y=dpCO2_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "point", 
                size=1.5, shape=21)+
    stat_summary(aes (x=Sub_region, y=dpCO2_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", 
               geom = "errorbar",  width = 0.2)
#dPCO2_Y3

dpH

Figure 4C

dOmega

Figure 4D

DOmega_exp<- Delta_plot_month+
   scale_y_continuous(#limits = c(1,5.5),
                       name=(expression (paste(Delta ,
                          ~Omega[Ar]))),
                       breaks = seq(-3, 3, 0.5),
                       expand = c(0.05, 0.05)
                        ) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=dOme_MY, colour=Sub_region),
                span=0.8, se=F)+
      stat_summary(aes (x=as.numeric(Month2),
                      y=dOme_MY, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=dOme_MY, fill=Sub_region),
                 shape=21, size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))+
  facet_grid(Zone~.)

#DOmega_exp

om_delta_Y2<- DeltaYear_plot2+
    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.05, 0.05),
                     #breaks = seq(-800, 800, 50),
                      name=(expression (paste(Delta ,
                          ~Omega[Ar]))))+
    stat_summary(aes (x=Season, y=dAra_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "bar",
                position=position_dodge(width=0.8))+
    stat_summary(aes (x=Season, y=dAra_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.8))+
  theme(panel.spacing = unit(0.8, "lines"))
#om_delta_Y2

dOm_Y3<- DeltaYear_plot3+
   scale_y_continuous(#limits = c(-0.9, 1),
                     expand = c(0.02, 0.02),
                     breaks = seq(-5, 5, 0.5),
                     name=(expression (paste(Delta ,
                          ~Omega[Ar]))))+
    
   stat_summary(aes (x=Zone, y=dAra_mean, 
                     fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=1.5, position=position_dodge(width=0.5))+
    stat_summary(aes (x=Zone, y=dAra_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", 
                geom = "errorbar",   width = 0.2,
               position=position_dodge(width=0.5))
#dOm_Y3

- Figure 4: Seasonal Δ and yearly sums

Seasonality_deltas<-ggarrange(
          TA_delta_Y2 +theme(legend.position = "none",
                              axis.text.x=element_blank()),
          DIC_delta_Y2+theme(legend.position = "none",
                              strip.text.x = element_blank(),
                              axis.text.x=element_blank()), 
          pH_delta_Y2+theme(legend.position = "none",
                              strip.text.x = element_blank(),
                              axis.text.x=element_blank()), 
          om_delta_Y2+ theme(panel.spacing = unit(0.8, "lines"),
                              strip.text.x = element_blank()),
          #TA_DIC_sum,
          nrow = 4, 
          #labels = c("A", "B", " C"),
          heights =c(1, 0.9, 0.9, 1.2))
          #widths = c(1, 1, 0.9))
Seasonality_deltas

Seasonality_deltas3<-ggarrange(
          dTA_my3,
          dDIC_my3,
          dpH_my3,
          dOm_my3,
          nrow = 4, 
          #labels = c("A", "B", " C"),
          heights =c(1, 0.9, 0.9, 1))
Seasonality_deltas3

#ggsave(file="FLK_results/Figures/Fig_4/Fig_4_delta_season.svg", plot=Seasonality_deltas, dpi = 300, width=6, height=6)

#ggsave(file="FLK_results/Figures/Fig_4/Fig_4_delta_ICRS.svg", plot=Seasonality_deltas, dpi = 300, width=8, height=6)

#ggsave(file="FLK_results/Figures/Fig_4/Fig_4_delta_Summary.svg", plot=Seasonality_deltas3, dpi = 300, width=8, height=8)

Figure 4: Seasonal inshore-ocean gradients in the Florida Keys. (A) Seasonal ΔTA. (B) Seasonal ΔDIC. (C) Seasonal ΩAr. The bars represent the mean Δ values per season, region, and shelf position (± 95 CI).

5.4 Delta season values

- Delta season stats (all data)

  dSeason_Stats<- ddply (WS.reef, .(Zone, Sub_region, Season),
                            summarise,
                  dTA_mean = mean (dTA_MY, na.rm = T),
                  dTA_sd = sd (dTA_MY, na.rm = T),
                  
                  dnTA_mean = mean (dnTA_MY, na.rm = T),
                  dnTA_sd = sd (dnTA_MY, na.rm = T),
                 
                  dDIC_mean = mean (dDIC_MY, na.rm = T),
                  dDIC_sd = mean (dDIC_MY, na.rm = T),
                  
                  #dnDIC_mean = mean (dnDIC_MY, na.rm = T),
                  #dnDIC_sd = sd (dnDIC_MY, na.rm = T),
                  
                  #dpCO2_mean = mean (dpCO2_MY , na.rm = T),
                  #dpCO2_sd = sd (dpCO2_MY , na.rm = T),
                  
                  dpH_mean = mean (dpH_MY, na.rm = T),
                  dpH_sd = mean (dpH_MY, na.rm = T),
                  
                  dAra_mean = mean (dOme_MY , na.rm = T),
                  dAra_sd = mean (dOme_MY , na.rm = T),
                  n())

dSeason_Stats<-dSeason_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
dSeason_Stats

- Delta season stats (monthly mean)

dSeasonal_Stats2<- ddply (dMonth_Stats,
                          .(Zone, Season, Sub_region),
                         summarise,

                  dTA_M = mean (dTA_mean, na.rm = T),
                  dTA_sd = sd (dTA_mean, na.rm = T),
                  dTA_se = std.error (dTA_mean, na.rm = T),
                  
                  dDIC_M = mean (dDIC_mean, na.rm = T),
                  dDIC_sd = sd (dDIC_mean, na.rm = T),
                  dDIC_se = std.error (dDIC_mean, na.rm = T),
                  
                  #dnTA_M = mean (dnTA_mean, na.rm = T),
                  #dnTA_sd = sd (dnTA_mean, na.rm = T),
                  
                  #dnDIC_M = mean (dnDIC_mean, na.rm = T),
                  #dnDIC_sd = sd (dnDIC_mean, na.rm = T),

                  dpCO2_M = mean (dpCO2_mean , na.rm = T),
                  dpCO2_sd = sd (dpCO2_mean , na.rm = T),
                  dpCO2_se = std.error (dpCO2_mean , na.rm = T),

                  dpH_M = mean (dpH_mean, na.rm = T),
                  dpH_sd = sd (dpH_mean, na.rm = T),
                  dpH_se = std.error (dpH_mean, na.rm = T),

                  dAra_M = mean (dAra_mean , na.rm = T),
                  dAra_sd = sd (dAra_mean , na.rm = T),
                  dAra_se = std.error (dAra_mean , na.rm = T),
                  n())

dSeasonal_Stats2<-dSeasonal_Stats2 %>% 
 mutate_if(is.numeric, round, digits=3)
dSeasonal_Stats2
#write.csv(dSeasonal_Stats2, "FLK_results/Table_2_SeasonDelta_B.csv", row.names = F)

Note: SD is NA when calculating it based on monthly meand (n=3 per season)

- Delta yearly stats (monthly mean)

dYearly_Stats<- ddply (dMonth_Stats, .(Zone, Sub_region),
                         summarise,

                  dTA_M = mean (dTA_mean, na.rm = T),
                  dTA_sd = sd (dTA_mean, na.rm = T),
                  #dTA_se = std.error (dTA_mean, na.rm = T),
                  
                  dDIC_M = mean (dDIC_mean, na.rm = T),
                  dDIC_sd = sd (dDIC_mean, na.rm = T),
                  #dDIC_se = std.error (dDIC_mean, na.rm = T),
                  
                  dnTA_M = mean (dnTA_mean, na.rm = T),
                  dnTA_sd = sd (dnTA_mean, na.rm = T),
                  
                  dnDIC_M = mean (dnDIC_mean, na.rm = T),
                  dnDIC_sd = sd (dnDIC_mean, na.rm = T),

                  dpCO2_M = mean (dpCO2_mean , na.rm = T),
                  dpCO2_sd = sd (dpCO2_mean , na.rm = T),
                  #dpCO2_se = std.error (dpCO2_mean , na.rm = T),

                  dpH_M = mean (dpH_mean, na.rm = T),
                  dpH_sd = sd (dpH_mean, na.rm = T),
                  #dpH_se = std.error (dpH_mean, na.rm = T),

                  dAra_M = mean (dAra_mean , na.rm = T),
                  dAra_sd = sd (dAra_mean , na.rm = T),
                  #dAra_se = std.error (dAra_mean , na.rm = T),
                  n())

dYearly_Stats<-dYearly_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
dYearly_Stats
#write.csv(dYearly_Stats, "FLK_results/Table_1b_delta_year.csv", row.names = F)

- Yearly summ (monthly mean)

dYear_Add<- ddply (dMonth_Stats, .(Zone, Sub_region),
           summarise,
  su_dTA_Y = sum (dTA_mean, na.rm = T),
  #m_TA_Y = mean (dTA_mean, na.rm = T),
  #sd_TA_Y = sd (dTA_mean, na.rm = T),
  
  su_dDIC_Y = sum (dDIC_mean, na.rm = T),
  #m_dDIC_Y = mean (dDIC_mean, na.rm = T),
  #sd_dDIC_Y = sd (dDIC_mean, na.rm = T),
  

  su_dpCO2_Y = sum (dpCO2_mean, na.rm = T),
  #m_pCO2_Y = mean (dpCO2_mean, na.rm = T),
  #sd_pCO2_Y = sd (dpCO2_mean, na.rm = T),
  
  su_dpH_Y = sum (dpH_mean, na.rm = T),
  #m_pH_Y = mean (dpH_mean, na.rm = T),
  #sd_pH_Y = sd (dpH_mean, na.rm = T),
  
  su_dAra_Y = sum (dAra_mean, na.rm = T),
  #m_Ara_Y = mean (dAra_mean, na.rm = T),
  #sd_Ara_Y = sd (dAra_mean, na.rm = T),
  n())

dYear_Add<-dYear_Add %>% 
 mutate_if(is.numeric, round, digits=2)
dYear_Add
#write.csv(dYear_Add, "FLK_results/Table_1_year_byMM.csv", row.names = F)

- Yearly summ (indiviual years)

dYear_Add2<- ddply (WS.reef, .(Zone, Sub_region, MY, Region, Year),
                            summarise,
                  dTA_mean = mean (dTA_MY, na.rm = T),
                  dTA_sd = sd (dTA_MY, na.rm = T),
                  #dTA_se = std.error (dTA_MY, na.rm = T),
                  
                  dnTA_mean = mean (dnTA_MY, na.rm = T),
                  dnTA_sd = sd (dnTA_MY, na.rm = T),
                 
                  dDIC_mean = mean (dDIC_MY, na.rm = T),
                  dDIC_sd = mean (dDIC_MY, na.rm = T),
                  #dDIC_se = std.error (dDIC_MY, na.rm = T),
                  
                  dnDIC_mean = mean (dnDIC_MY, na.rm = T),
                  dnDIC_sd = sd (dnDIC_MY, na.rm = T),
                  
                  dpCO2_mean = mean (dpCO2_MY , na.rm = T),
                  dpCO2_sd = sd (dpCO2_MY , na.rm = T),
                  #dpCO2_se = std.error (dpCO2_MY, na.rm = T),
                  
                  dpH_mean = mean (dpH_MY, na.rm = T),
                  dpH_sd = mean (dpH_MY, na.rm = T),
                  #dPH_se = std.error (dpH_MY, na.rm = T),
                  
                  dAra_mean = mean (dOme_MY , na.rm = T),
                  dAra_sd = mean (dOme_MY , na.rm = T),
                  #dAra_se = std.error (dOme_MY, na.rm = T),
                  n())

dYear_Add2<-dYear_Add2 %>% 
 mutate_if(is.numeric, round, digits=3)
dYear_Add2
dYear_Add2<-dYear_Add2[dYear_Add2$Year>2014, ]
dYear_Add2<-dYear_Add2[dYear_Add2$Year<2022, ]

dYear_Add3<- ddply (dYear_Add2, .(Zone, Sub_region, Year),
           summarise,
  su_dTA_Y = sum (dTA_mean, na.rm = T),
  #m_TA_Y = mean (dTA_mean, na.rm = T),
  #sd_TA_Y = sd (dTA_mean, na.rm = T),
  
  su_dDIC_Y = sum (dDIC_mean, na.rm = T),
  #m_dDIC_Y = mean (dDIC_mean, na.rm = T),
  #sd_dDIC_Y = sd (dDIC_mean, na.rm = T),
  

  su_dpCO2_Y = sum (dpCO2_mean, na.rm = T),
  #m_pCO2_Y = mean (dpCO2_mean, na.rm = T),
  #sd_pCO2_Y = sd (dpCO2_mean, na.rm = T),
  
  su_dpH_Y = sum (dpH_mean, na.rm = T),
  #m_pH_Y = mean (dpH_mean, na.rm = T),
  #sd_pH_Y = sd (dpH_mean, na.rm = T),
  
  su_dAra_Y = sum (dAra_mean, na.rm = T),
  #m_Ara_Y = mean (dAra_mean, na.rm = T),
  #sd_Ara_Y = sd (dAra_mean, na.rm = T),
  n())

dYear_Add3<-dYear_Add3 %>% 
 mutate_if(is.numeric, round, digits=2)
dYear_Add3

5.5 Seasonal models

season.data<-WS.reef[WS.reef$Extreme=="Normal", ]
season.data<-droplevels(season.data)
season.data$Zone<-factor(season.data$Zone, levels = c("Offshore", "Mid channel", "Inshore"))
#summary(season.data)

inshore.season.data<-season.data[season.data$Zone=="Inshore", ]
midchanel.season.data<-season.data[season.data$Zone=="Mid channel", ]
ofshore.season.data<-season.data[season.data$Zone=="Offshore", ]

LMER - TA month

  hist(FLK.data_filtered$TA_umol_kg)

  shapiro.test(FLK.data_filtered$TA_umol_kg) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  FLK.data_filtered$TA_umol_kg
## W = 0.8038, p-value < 2.2e-16
# 
#   dTA_season<-lmer(dTA_MY~  Zone + Sub_region + Season +
#                            Zone:Sub_region + Zone:Season + Sub_region:Season+   
#                            (1|SiteID), data=season.data)
  
  TA_month_0<-lmer(TA_umol_kg~  Zone * Sub_region * Month +
                           (1|SiteID), data=FLK.data_filtered)
  #anova(TA_month_0)
  
  TA_month<-lmer(TA_umol_kg~  Zone + Sub_region + Month +
                              Zone:Sub_region + Zone:Month + Sub_region:Month +
                              (1|SiteID), data=season.data)
  
  #summary(dTA_season)    
  av.TA_month<-(anova(TA_month))
  av.TA_month
  ranova(TA_month)
  #step(TA_month)
  
  plot(TA_month)

  par(mfrow=c(1,2))
  qqnorm(resid(TA_month))
  acf(resid(TA_month), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  
  #summ(TA_month, scale = TRUE)
  #plot_summs(TA_month)
  
  TA_mo.emmc<-emmeans(TA_month, ~Zone*Month, by="Sub_region")
    TA_mon.emmc<-multcomp::cld(TA_mo.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    #TA_mon.emmc<-TA_mon.emmc[order(TA_mon.emmc$Zone, TA_mon.emmc$Month), ]
  TA_mon.emmc

LMER - TA season

  hist(season.data$TA_umol_kg)

  shapiro.test(season.data$TA_umol_kg) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$TA_umol_kg
## W = 0.83476, p-value < 2.2e-16
# 
#   dTA_season<-lmer(dTA_MY~  Zone + Sub_region + Season +
#                            Zone:Sub_region + Zone:Season + Sub_region:Season+   
#                            (1|SiteID), data=season.data)
  
  TA_season_0<-lmer(TA_umol_kg~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  anova(TA_season_0)
  TA_season<-lmer(TA_umol_kg~ Zone + Sub_region + Season +
                              Zone:Sub_region + 
                              Zone:Season + 
                              Sub_region:Season +
                              (1|SiteID), data=season.data)
  anova(TA_season_0, TA_season)
  #summary(av.TA_season)    
  av.TA_season<-(anova(TA_season))
  av.TA_season
  ranova(TA_season)
  #step(TA_season)
  
  plot(TA_season)

  par(mfrow=c(1,2))
  qqnorm(resid(TA_season))
  acf(resid(TA_season), main="acf(resid(TA Season))")

  par(mfrow=c(1,1))
  
  #summ(av.TA_season, scale = TRUE)
  #plot_summs(TA_season)
  
  TA_se.emmc<-emmeans(TA_season, ~Zone*Season, by="Sub_region")
    TA_seas.emmc<-multcomp::cld(TA_se.emmc)
    TA_seas.emmc
  TA_se.emmc2<-emmeans(TA_season, ~Sub_region*Season, by="Zone")
    TA_seas.emmc2<-multcomp::cld(TA_se.emmc2)
    TA_seas.emmc2

LMER - all dTA - MODEL 13

  hist(season.data$dTA_MY)

  shapiro.test(season.data$dTA_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dTA_MY
## W = 0.81662, p-value < 2.2e-16
# 
#   dTA_season<-lmer(dTA_MY~  Zone + Sub_region + Season +
#                            Zone:Sub_region + Zone:Season + Sub_region:Season+   
#                            (1|SiteID), data=season.data)
  
  dTA_season<-lmer(dTA_MY~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dTA_season)    
  av.dTA_season<-(anova(dTA_season))
  av.dTA_season
  ranova(dTA_season)
  #step(dTA_season)
  
  plot(dTA_season)

  par(mfrow=c(1,2))
  qqnorm(resid(dTA_season))
  acf(resid(dTA_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  
  #summ(dTA_season, scale = TRUE)
  #plot_summs(dTA_season)
 dTA_ses.emmc<-emmeans(dTA_season, ~Season*Sub_region, by="Zone")
    dTA_ses.emmc<-multcomp::cld(dTA_ses.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dTA_ses.emmc<-dTA_ses.emmc[order(dTA_ses.emmc$Zone, 
                                     dTA_ses.emmc$Season, 
                                     dTA_ses.emmc$Sub_region), ]
  dTA_ses.emmc
  dTA_ses.emmc[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                 caption = "Seasonal dTA") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal dTA
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB 1.15 12.34 202.53 -23.19 25.49 1
Winter UK 4.02 10.57 233.81 -16.81 24.86 1
Winter MK 4.70 10.17 209.03 -15.34 24.75 1
Winter LK 2.05 8.73 200.55 -15.18 19.27 1
Spring BB -3.59 11.75 166.82 -26.80 19.61 1
Spring UK -1.76 9.99 195.01 -21.47 17.95 1
Spring MK -7.08 9.23 148.06 -25.32 11.17 1
Spring LK -11.23 7.94 143.27 -26.93 4.47 1
Summer BB -5.51 12.69 223.40 -30.51 19.49 1
Summer UK -4.76 10.79 252.32 -26.00 16.49 1
Summer MK -24.72 10.36 223.40 -45.13 -4.30 1
Summer LK -10.43 8.97 223.40 -28.11 7.24 1
Fall BB -0.84 11.48 155.23 -23.51 21.84 1
Fall UK -0.58 9.99 196.41 -20.28 19.13 1
Fall MK -1.32 9.23 148.06 -19.56 16.92 1
Fall LK -3.36 8.03 149.52 -19.22 12.50 1
Mid-Channel
Winter BB 8.13 12.69 223.40 -16.87 33.13 34
Winter UK 10.78 13.07 246.09 -14.96 36.52 34
Winter MK 25.33 10.17 209.04 5.28 45.38 4
Winter LK 13.63 9.37 155.69 -4.88 32.13 4
Spring BB -8.24 12.70 220.76 -33.26 16.78 234
Spring UK -2.67 12.34 202.49 -27.01 21.66 234
Spring MK -36.96 9.10 140.60 -54.95 -18.96 123
Spring LK -48.59 8.86 127.36 -66.13 -31.05 12
Summer BB -13.78 12.69 223.40 -38.78 11.22 234
Summer UK -5.59 13.50 270.08 -32.16 20.99 234
Summer MK -73.30 10.36 223.40 -93.71 -52.89 1
Summer LK -76.55 10.36 223.40 -96.96 -56.13 1
Fall BB 4.07 11.74 169.57 -19.11 27.24 34
Fall UK 0.63 12.34 202.49 -23.71 24.97 234
Fall MK 7.17 9.37 156.40 -11.33 25.67 4
Fall LK -11.66 8.98 133.90 -29.42 6.10 234
Inshore
Winter BB 40.69 12.34 202.54 16.35 65.03 67
Winter UK 48.86 11.02 271.46 27.17 70.55 67
Winter MK 71.49 10.56 238.06 50.68 92.30 7
Winter LK 7.31 9.67 172.74 -11.77 26.39 56
Spring BB -62.31 11.75 166.85 -85.51 -39.10 4
Spring UK -56.82 10.36 223.40 -77.23 -36.41 4
Spring MK -80.56 8.86 127.35 -98.10 -63.03 34
Spring LK -124.04 8.75 121.46 -141.36 -106.72 23
Summer BB -46.25 12.69 223.40 -71.25 -21.25 45
Summer UK -35.23 10.36 223.40 -55.65 -14.82 45
Summer MK -155.72 10.36 223.40 -176.13 -135.30 12
Summer LK -195.69 10.36 223.40 -216.10 -175.28 1
Fall BB 26.23 11.23 144.22 4.04 48.42 67
Fall UK 44.42 10.36 223.40 24.01 64.83 67
Fall MK 16.75 9.37 155.65 -1.76 35.26 6
Fall LK -63.22 8.98 133.90 -80.98 -45.46 4
  dTA_year.emmc<-emmeans(dTA_season, ~Sub_region*Zone)
    dTA_year.emmc<-multcomp::cld(dTA_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dTA_year.emmc<-dTA_year.emmc[order(dTA_year.emmc$Zone, 
                                      dTA_year.emmc$Sub_region), ]
  #dTA_year.emmc
  
  dTA_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year dTA") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year dTA
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB -2.20 6.87 21.17 -16.47 12.08 34
UK -0.77 5.82 24.60 -12.76 11.22 4
MK -7.10 5.56 20.63 -18.68 4.48 34
LK -5.75 4.81 20.39 -15.76 4.27 34
Mid-Channel
BB -2.46 7.03 23.41 -16.99 12.08 34
UK 0.79 7.20 25.61 -14.02 15.59 34
MK -19.44 5.56 20.64 -31.02 -7.86 234
LK -30.79 5.41 18.44 -42.13 -19.45 23
Inshore
BB -10.41 6.84 20.88 -24.64 3.82 234
UK 0.31 5.90 26.11 -11.82 12.43 4
MK -37.01 5.58 20.96 -48.62 -25.40 2
LK -93.91 5.43 18.72 -105.29 -82.53 1

Figure 4A: Model

dTA_ses_2.emmc<-as.data.frame(dTA_ses.emmc)
dTA_ye_3.emmc<-as.data.frame(dTA_year.emmc)
dTA_ye_3.emmc$Season<-"Mean"

dTA_all_4<-rbind(dTA_ses_2.emmc, dTA_ye_3.emmc)
dTA_all_4$Zone<-factor(dTA_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearTA<- ggplot(dTA_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "TA  (", mu, "mol ", ~kg^-1, ")")))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 
DeltaYearTA

LMER - dTA Inshore

# Inshore dTA
  hist(inshore.season.data$dTA_MY)

  shapiro.test(inshore.season.data$dTA_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$dTA_MY
## W = 0.96933, p-value = 2.109e-07
  dTA_season_in<-lmer(dTA_MY~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
  #summary(dTA_season_in)    
  av.dTA_season_in<-anova(dTA_season_in)
  av.dTA_season_in
  ranova(dTA_season_in)
  #step(dTA_season_in)
  
  plot(dTA_season_in)

  par(mfrow=c(1,2))
  qqnorm(resid(dTA_season_in))
  acf(resid(dTA_season_in), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #summ(dTA_season_in, scale = TRUE)
  #plot_summs(dTA_season_in)
  
  dTA_ses_in.emmc<-emmeans(dTA_season_in, ~ Sub_region*Season)
    dTA_ses_in.emmc<-multcomp::cld(dTA_ses_in.emmc)
    #dTA_ses_in.emmc<-as.data.frame(dTA_ses_in.emmc[complete.cases(dTA_ses_in.emmc),])
    dTA_ses_in.emmc<-dTA_ses_in.emmc[order(dTA_ses_in.emmc$Season,
                                           dTA_ses_in.emmc$Sub_region), ]
  dTA_ses_in.emmc

LMER - DIC season

  hist(season.data$DIC_umol_kg)

  shapiro.test(season.data$DIC_umol_kg) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$DIC_umol_kg
## W = 0.90935, p-value < 2.2e-16
  DIC_season_0<-lmer(DIC_umol_kg~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  

  #summary(DIC_season_0)    
  av.DIC_season<-(anova(DIC_season_0))
  av.DIC_season
  ranova(DIC_season_0)
  #step(DIC_season_0)
  
  plot(DIC_season_0)

  par(mfrow=c(1,2))
  qqnorm(resid(DIC_season_0))
  acf(resid(DIC_season_0), main="acf(resid(DIC Season))")

  par(mfrow=c(1,1))
  
  #summ(av.TA_season, scale = TRUE)
  #plot_summs(av.DIC_season)
  
  DIC_se.emmc<-emmeans(DIC_season_0, ~Zone*Season, by="Sub_region")
    DIC_seas.emmc<-multcomp::cld(DIC_se.emmc)
    DIC_seas.emmc
  DIC_se.emmc2<-emmeans(DIC_season_0, ~Sub_region*Season, by="Zone")
    DIC_seas.emmc2<-multcomp::cld(TA_se.emmc2)
    DIC_seas.emmc2

LMER - all dDIC - MODEL 14

# Inshore Omega
  hist(season.data$dDIC_MY)

  shapiro.test(season.data$dDIC_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dDIC_MY
## W = 0.87617, p-value < 2.2e-16
  # dDIC_season<-lmer(dDIC_MY~ Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  
  dDIC_season<-lmer(dDIC_MY~ Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dDIC_season)    
  av.dDIC_season<-anova(dDIC_season)
  av.dDIC_season
  ranova(dDIC_season)
  step(dDIC_season)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC    LRT Df Pr(>Chisq)  
## <none>                    50 -6105.6 12311                       
## (1 | SiteID)          0   49 -6107.6 12313 4.0645  1    0.04379 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                        Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)
## Zone:Sub_region:Season          0 115256  6403.1    18 1116.2  2.6592 0.0001976
##                           
## Zone:Sub_region:Season ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Zone * Sub_region * Season + (1 | SiteID)
  plot(dDIC_season)

  par(mfrow=c(1,2))
  qqnorm(resid(dDIC_season))
  acf(resid(dDIC_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #summ(dDIC_season, scale = TRUE)
  #plot_summs(dDIC_season)
  
 dDIC_ses.emmc<-emmeans(dDIC_season, ~Season*Sub_region, by="Zone")
    dDIC_ses.emmc<-multcomp::cld(dDIC_ses.emmc)
    #dDIC_ses.emmc<-as.data.frame(dDIC_ses.emmc[complete.cases(dDIC_ses.emmc),])
    dDIC_ses.emmc<-dDIC_ses.emmc[order(dDIC_ses.emmc$Zone, 
                                     dDIC_ses.emmc$Season, 
                                     dDIC_ses.emmc$Sub_region), ]
  #dDIC_ses.emmc

  dDIC_ses.emmc[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                 caption = "Seasonal dDIC") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal dDIC
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB -3.29 12.87 162.21 -28.71 22.13 1
Winter UK -2.52 11.00 187.84 -24.22 19.19 1
Winter MK 5.75 10.60 167.29 -15.18 26.68 1
Winter LK 5.28 8.89 147.46 -12.30 22.85 1
Spring BB -2.60 12.30 135.18 -26.92 21.72 1
Spring UK -3.02 10.43 156.68 -23.62 17.58 1
Spring MK -16.19 9.68 119.88 -35.35 2.98 1
Spring LK -7.97 8.33 116.47 -24.48 8.53 1
Summer BB 5.88 13.21 178.41 -20.19 31.95 1
Summer UK -3.02 11.21 202.07 -25.12 19.09 1
Summer MK -20.44 10.79 178.41 -41.72 0.85 1
Summer LK 0.36 9.75 207.11 -18.87 19.58 1
Fall BB 3.58 12.03 125.68 -20.22 27.37 1
Fall UK 2.72 10.42 157.42 -17.87 23.31 1
Fall MK 0.39 9.68 119.88 -18.78 19.56 1
Fall LK 1.18 8.41 121.15 -15.48 17.84 1
Mid-Channel
Winter BB 8.37 13.21 178.41 -17.70 34.44 34
Winter UK -0.72 13.59 196.52 -27.51 26.08 234
Winter MK 22.28 10.60 167.29 1.35 43.21 34
Winter LK 29.98 9.82 125.91 10.55 49.41 4
Spring BB -24.36 13.22 177.04 -50.46 1.73 1234
Spring UK -31.40 12.87 162.18 -56.82 -5.98 123
Spring MK -68.20 9.55 114.12 -87.12 -49.27 1
Spring LK -57.02 9.32 103.91 -75.50 -38.53 12
Summer BB 4.03 13.21 178.41 -22.04 30.10 34
Summer UK -3.04 14.01 216.44 -30.66 24.58 234
Summer MK -59.92 10.79 178.41 -81.21 -38.64 12
Summer LK -57.81 11.20 203.50 -79.90 -35.72 12
Fall BB 22.18 12.28 136.54 -2.10 46.47 34
Fall UK 15.76 12.87 162.18 -9.66 41.18 34
Fall MK 22.59 9.81 126.26 3.17 42.01 34
Fall LK 5.03 9.43 108.90 -13.67 23.73 34
Inshore
Winter BB 44.75 12.87 162.22 19.33 70.17 345
Winter UK 40.45 11.44 217.19 17.90 63.00 34
Winter MK 66.54 10.99 190.14 44.86 88.21 45
Winter LK 26.00 10.11 139.51 6.01 45.99 234
Spring BB -92.98 12.30 135.20 -117.30 -68.66 1
Spring UK -126.79 10.79 178.41 -148.07 -105.50 1
Spring MK -132.74 9.32 103.91 -151.23 -114.26 1
Spring LK -135.06 9.21 99.36 -153.34 -116.79 1
Summer BB -10.42 13.21 178.41 -36.49 15.65 23
Summer UK -25.40 10.79 178.41 -46.69 -4.12 2
Summer MK -130.46 10.79 178.41 -151.75 -109.18 1
Summer LK -107.78 11.43 218.75 -130.31 -85.25 1
Fall BB 73.32 11.78 116.93 49.99 96.65 45
Fall UK 96.30 10.79 178.41 75.01 117.59 5
Fall MK 50.21 9.82 125.89 30.78 69.64 45
Fall LK -7.47 9.43 108.90 -26.17 11.23 23
  dDIC_year.emmc<-emmeans(dDIC_season, ~Sub_region*Zone)
    dDIC_year.emmc<-multcomp::cld(dDIC_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dDIC_year.emmc<-dDIC_year.emmc[order(dDIC_year.emmc$Zone, 
                                      dDIC_year.emmc$Sub_region), ]
  #dDIC_year.emmc
  
  dDIC_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year dDIC") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year dDIC
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB 0.89 7.61 21.01 -14.93 16.71 3
UK -1.46 6.41 23.83 -14.68 11.77 3
MK -7.62 6.17 20.53 -20.46 5.22 23
LK -0.29 5.36 20.69 -11.44 10.86 3
Mid-Channel
BB 2.55 7.76 22.84 -13.51 18.61 3
UK -4.85 7.91 24.65 -21.15 11.45 23
MK -20.81 6.17 20.54 -33.66 -7.97 23
LK -19.95 6.07 19.30 -32.65 -7.26 23
Inshore
BB 3.67 7.58 20.76 -12.11 19.44 3
UK -3.86 6.48 25.04 -17.21 9.49 3
MK -36.62 6.19 20.81 -49.49 -23.74 12
LK -56.08 6.12 19.88 -68.85 -43.31 1

Figure 4B: Model

dDIC_ses_2.emmc<-as.data.frame(dDIC_ses.emmc)
dDIC_ye_3.emmc<-as.data.frame(dDIC_year.emmc)
dDIC_ye_3.emmc$Season<-"Mean"

dDIC_all_4<-rbind(dDIC_ses_2.emmc, dDIC_ye_3.emmc)
dDIC_all_4$Zone<-factor(dDIC_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearDIC<- ggplot(dDIC_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "DIC  (", mu, "mol ", ~kg^-1, ")")))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 
DeltaYearDIC

LMER - dDIC Inshore

# Inshore dDIC
  hist(inshore.season.data$dDIC_MY)

  shapiro.test(inshore.season.data$dDIC_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$dDIC_MY
## W = 0.99355, p-value = 0.09112
  dDIC_season_in<-lmer(dDIC_MY~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
  #summary(dDIC_season_in)    
  av.dDIC_season_in<-anova(dDIC_season_in)
  av.dDIC_season_in
  ranova(dDIC_season_in)
  #step(dDIC_season_in)
  
  plot(dDIC_season_in)

  par(mfrow=c(1,1))
  qqnorm(resid(dDIC_season_in))

  acf(resid(dDIC_season_in), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #summ(dDIC_season_in, scale = TRUE)
  #plot_summs(dDIC_season_in)
  
  dDIC_ses_in.emmc<-emmeans(dDIC_season_in, ~ Sub_region*Season)
    dDIC_ses_in.emmc<-multcomp::cld(dDIC_ses_in.emmc)
    #dDIC_ses_in.emmc<-as.data.frame(dDIC_ses_in.emmc[complete.cases(dDIC_ses_in.emmc),])
    dDIC_ses_in.emmc<-dDIC_ses_in.emmc[order(dDIC_ses_in.emmc$Season,
                                           dDIC_ses_in.emmc$Sub_region), ]
  dDIC_ses_in.emmc

LMER - all dpCO2

# Inshore Omega
  hist(season.data$dpCO2_MY)

  shapiro.test(season.data$dpCO2_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dpCO2_MY
## W = 0.91004, p-value < 2.2e-16
  # dpCO2_season<-lmer(dpCO2_MY~ Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  dpCO2_season<-lmer(dpCO2_MY~ Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dpCO2_season)    
  av.dPCO2_season<-anova(dpCO2_season)
  av.dPCO2_season
  ranova(dpCO2_season)
  step(dpCO2_season)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC    LRT Df Pr(>Chisq)  
## <none>                    50 -6199.1 12498                       
## (1 | SiteID)          0   49 -6201.7 12501 5.0745  1    0.02428 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                        Eliminated Sum Sq Mean Sq NumDF   DenDF F value
## Zone:Sub_region:Season          1  83814    4656    18 1113.09  1.6110
## Zone:Sub_region                 2  21144    3524     6   21.92  1.2075
## Zone:Season                     0 643024  107171     6 1132.67 36.7311
## Sub_region:Season               0  76429    8492     9 1131.81  2.9105
##                           Pr(>F)    
## Zone:Sub_region:Season  0.050486 .  
## Zone:Sub_region         0.339593    
## Zone:Season            < 2.2e-16 ***
## Sub_region:Season       0.002061 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dpCO2_MY ~ Zone + Sub_region + Season + (1 | SiteID) + Zone:Season + Sub_region:Season
  plot(dpCO2_season)

  par(mfrow=c(1,2))
  qqnorm(resid(dpCO2_season))
  acf(resid(dpCO2_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #plot_summs(dpCO2_season)  
  
  dpCO2_ses.emmc<-emmeans(dpCO2_season, ~Zone*Sub_region*Season)
    dpCO2_ses.emmc<-multcomp::cld(dpCO2_ses.emmc)
    #dpCO2_ses.emmc<-as.data.frame(dpCO2_ses.emmc[complete.cases(dpCO2_ses.emmc),])
    dpCO2_ses.emmc<-dpCO2_ses.emmc[order(dpCO2_ses.emmc$Zone, dpCO2_ses.emmc$Season), ]
  dpCO2_ses.emmc
  #summ(dpCO2_season, scale = TRUE)

LMER - dpCO2 Inshore

# Inshore dDIC
  hist(inshore.season.data$dpCO2_MY)

  shapiro.test(inshore.season.data$dpCO2_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$dpCO2_MY
## W = 0.97502, p-value = 2.647e-06
  dpCO2_season_in<-lmer(dpCO2_MY~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
  #summary(dpCO2_season_in)    
  av.dPCO2_season_in<-anova(dpCO2_season_in)
  av.dPCO2_season_in
  ranova(dpCO2_season_in)
  #step(dpCO2_season_in)
  
  plot(dpCO2_season_in)

  par(mfrow=c(1,2))
  qqnorm(resid(dpCO2_season_in))
  acf(resid(dpCO2_season_in), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #summ(dpCO2_season_in, scale = TRUE)
  #plot_summs(dpCO2_season_in)
  
  dpCO2_ses_in.emmc<-emmeans(dpCO2_season_in, ~ Sub_region*Season)
    dpCO2_ses_in.emmc<-multcomp::cld(dpCO2_ses_in.emmc)
    #dpCO2_ses_in.emmc<-as.data.frame(dpCO2_ses_in.emmc[complete.cases(dpCO2_ses_in.emmc),])
    dpCO2_ses_in.emmc<-dpCO2_ses_in.emmc[order(dpCO2_ses_in.emmc$Season,
                                           dpCO2_ses_in.emmc$Sub_region), ]
  dpCO2_ses_in.emmc

LMER - all Omega

# Inshore Omega
  hist(season.data$Aragonite_Sat_W)

  shapiro.test(season.data$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$Aragonite_Sat_W
## W = 0.97358, p-value = 5.782e-14
  # Omega_season<-lmer(Aragonite_Sat_W~  Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  Omega_season<-lmer(Aragonite_Sat_W~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(Omega_season)    
  av.Ome_season<-anova(Omega_season)
  av.Ome_season
  ranova(Omega_season)
  #step(Omega_season)
  
  plot(Omega_season)

  par(mfrow=c(1,2))
  qqnorm(resid(Omega_season))
  acf(resid(Omega_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #plot_summs(Omega_season)  
    
  # Ara_ses.emmc<-emmeans(Omega_season, ~Zone*Sub_region*Season)
  #   Ara_ses.emmc<-multcomp::cld(Ara_ses.emmc)
  #   Ara_ses.emmc<-as.data.frame(Ara_ses.emmc[complete.cases(Ara_ses.emmc),])
  #   Ara_ses.emmc<-Ara_ses.emmc[order(Ara_ses.emmc$Zone, Ara_ses.emmc$Season), ]
  # Ara_ses.emmc
  
  Ara_ses.emmc<-emmeans(Omega_season, ~Zone*Season, by="Sub_region")
    Ara_ses.emmc<-multcomp::cld(Ara_ses.emmc)
    Ara_ses.emmc
  Ara_ses.emmc2<-emmeans(Omega_season, ~Sub_region*Season, by="Zone")
    Ara_ses.emmc2<-multcomp::cld(Ara_ses.emmc2)
    Ara_ses.emmc2

LMER - all dOmega - MODEL 16

# Inshore Omega
  hist(season.data$dOme_MY)

  shapiro.test(season.data$dOme_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dOme_MY
## W = 0.95185, p-value < 2.2e-16
  # Omega_season<-lmer(Aragonite_Sat_W~  Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  dOmega_season<-lmer(dOme_MY~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dOmega_season)    
  av.dOme_season<-anova(dOmega_season)
  av.dOme_season
  ranova(dOmega_season)
  #step(dOmega_season)
  
  plot(dOmega_season)

  par(mfrow=c(1,2))
  qqnorm(resid(dOmega_season))
  acf(resid(dOmega_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #plot_summs(dOmega_season)  
    
dAra_ses.emmc<-emmeans(dOmega_season, ~Zone*Season, by="Sub_region")
    dAra_ses.emmc<-multcomp::cld(dAra_ses.emmc)
    dAra_ses.emmc
dAra_ses.emmc1<-emmeans(dOmega_season, ~Sub_region*Season, by="Zone")
    dAra_ses.emmc1<-multcomp::cld(dAra_ses.emmc1)
    dAra_ses.emmc1
dAra_ses.emmc2<-emmeans(dOmega_season, ~Season*Sub_region, by="Zone")
    dAra_ses.emmc2<-multcomp::cld(dAra_ses.emmc2)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dAra_ses.emmc2<-dAra_ses.emmc2[order(dAra_ses.emmc2$Zone, 
                                     dAra_ses.emmc2$Season, 
                                     dAra_ses.emmc2$Sub_region), ]

dAra_ses.emmc2[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                 caption = "Seasonal d Omega") %>%
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal d Omega
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB 0.04 0.07 195.69 -0.10 0.19 1
Winter UK 0.06 0.06 226.05 -0.06 0.19 1
Winter MK -0.02 0.06 201.96 -0.14 0.10 1
Winter LK -0.05 0.05 193.83 -0.15 0.06 1
Spring BB -0.01 0.07 161.37 -0.15 0.13 1
Spring UK 0.01 0.06 188.48 -0.11 0.13 1
Spring MK 0.09 0.06 143.17 -0.02 0.20 1
Spring LK -0.04 0.05 138.59 -0.14 0.05 1
Summer BB -0.13 0.08 215.81 -0.28 0.02 1
Summer UK -0.03 0.07 243.89 -0.16 0.10 1
Summer MK -0.07 0.06 215.81 -0.19 0.05 1
Summer LK -0.15 0.06 250.72 -0.26 -0.04 1
Fall BB -0.05 0.07 150.12 -0.19 0.09 1
Fall UK -0.04 0.06 189.78 -0.16 0.08 1
Fall MK -0.02 0.06 143.17 -0.13 0.09 1
Fall LK -0.06 0.05 144.59 -0.15 0.04 1
Mid-Channel
Winter BB -0.02 0.08 215.81 -0.17 0.13 123456
Winter UK 0.11 0.08 237.77 -0.05 0.26 23456
Winter MK 0.02 0.06 201.96 -0.10 0.14 2345
Winter LK -0.17 0.06 150.53 -0.28 -0.06 1234
Spring BB 0.16 0.08 213.37 0.01 0.31 456
Spring UK 0.30 0.07 195.64 0.15 0.44 56
Spring MK 0.30 0.06 135.99 0.19 0.41 6
Spring LK 0.06 0.05 123.24 -0.05 0.16 3456
Summer BB -0.21 0.08 215.81 -0.36 -0.06 123
Summer UK -0.03 0.08 261.11 -0.19 0.13 123456
Summer MK -0.20 0.06 215.81 -0.32 -0.07 123
Summer LK -0.32 0.07 246.30 -0.45 -0.19 1
Fall BB -0.20 0.07 163.90 -0.34 -0.06 123
Fall UK -0.17 0.07 195.64 -0.31 -0.02 1234
Fall MK -0.17 0.06 151.19 -0.28 -0.05 1234
Fall LK -0.19 0.05 129.53 -0.30 -0.08 12
Inshore
Winter BB -0.04 0.07 195.69 -0.19 0.11 678
Winter UK 0.08 0.07 262.40 -0.06 0.21 78
Winter MK 0.07 0.06 230.00 -0.06 0.20 78
Winter LK -0.22 0.06 167.01 -0.33 -0.10 4567
Spring BB 0.26 0.07 161.40 0.12 0.41 89
Spring UK 0.67 0.06 215.81 0.55 0.79 0
Spring MK 0.47 0.05 123.24 0.37 0.58 90
Spring LK 0.03 0.05 117.56 -0.08 0.13 78
Summer BB -0.41 0.08 215.81 -0.56 -0.26 2345
Summer UK -0.12 0.06 215.81 -0.24 0.01 567
Summer MK -0.42 0.06 215.81 -0.54 -0.29 2345
Summer LK -0.86 0.07 265.06 -0.99 -0.73 1
Fall BB -0.48 0.07 139.48 -0.62 -0.35 234
Fall UK -0.52 0.06 215.81 -0.65 -0.40 23
Fall MK -0.35 0.06 150.50 -0.46 -0.24 3456
Fall LK -0.65 0.05 129.53 -0.76 -0.54 12
dOm_year.emmc<-emmeans(dOmega_season, ~Sub_region*Zone)
    dOm_year.emmc<-multcomp::cld(dOm_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dOm_year.emmc<-dOm_year.emmc[order(dOm_year.emmc$Zone, 
                                      dOm_year.emmc$Sub_region), ]
  #dDIC_year.emmc
  
  dOm_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year d Omega") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year d Omega
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB -0.04 0.04 20.95 -0.12 0.05 23
UK 0.00 0.04 24.28 -0.07 0.07 23
MK -0.01 0.03 20.42 -0.08 0.07 23
LK -0.07 0.03 21.00 -0.13 -0.01 23
Mid-Channel
BB -0.07 0.04 23.12 -0.16 0.02 23
UK 0.05 0.04 25.25 -0.04 0.14 3
MK -0.01 0.03 20.43 -0.08 0.06 23
LK -0.16 0.03 18.99 -0.23 -0.09 2
Inshore
BB -0.17 0.04 20.67 -0.25 -0.08 23
UK 0.03 0.04 25.73 -0.05 0.10 3
MK -0.06 0.03 20.74 -0.13 0.01 23
LK -0.42 0.03 19.66 -0.50 -0.35 1

Figure 4D: Model

dAra_ses_2.emmc<-as.data.frame(dAra_ses.emmc2)
dAra_ye_3.emmc<-as.data.frame(dOm_year.emmc)
dAra_ye_3.emmc$Season<-"Mean"

dAra_all_4<-rbind(dAra_ses_2.emmc, dAra_ye_3.emmc)
dAra_all_4$Zone<-factor(dDIC_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearAra<- ggplot(dAra_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     breaks = seq(-6, 6, 0.3),
                     name=(expression (paste(Delta ,
                          ~Omega[Ar]))))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 

DeltaYearAra

LMER - Omega Inshore

# Inshore dOmega
  hist(inshore.season.data$Aragonite_Sat_W)

  shapiro.test(inshore.season.data$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$Aragonite_Sat_W
## W = 0.9918, p-value = 0.02632
  Omega_season_in<-lmer(Aragonite_Sat_W~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
      #summary(Omega_season_in)    
      av.Ome_season_in<-anova(Omega_season_in)
      av.Ome_season_in
      ranova(Omega_season_in)
      #step(Omega_season_in)
      
      plot(Omega_season_in)

      par(mfrow=c(1,2))
      qqnorm(resid(Omega_season_in))
      acf(resid(Omega_season_in), main="acf(resid(dTA Season))")

      par(mfrow=c(1,1))
      #summ(dDIC_season_in, scale = TRUE)
  #plot_summs(Omega_season_in)
  
  omega_ses_in.emmc<-emmeans(Omega_season_in, ~ Sub_region*Season)
    omega_ses_in.emmc<-multcomp::cld(omega_ses_in.emmc)
    #omega_ses_in.emmc<-as.data.frame(omega_ses_in.emmc[complete.cases(omega_ses_in.emmc),])
    omega_ses_in.emmc<-omega_ses_in.emmc[order(omega_ses_in.emmc$Season,
                                           omega_ses_in.emmc$Sub_region), ]
  omega_ses_in.emmc

LMER - all pH

# Inshore Omega
  hist(season.data$pH_calculated)

  shapiro.test(season.data$pH_calculated) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$pH_calculated
## W = 0.97272, p-value = 3.157e-14
  # pH_season<-lmer(pH_calculated~ Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  pH_season<-lmer(pH_calculated~ Zone * Sub_region * Season *
                           (1|SiteID), data=season.data)
  
        #summary(pH_season)    
        av.pH_season<-anova(pH_season)
        av.pH_season
        ranova(pH_season)
        #step(pH_season)
        
        plot(pH_season)

        par(mfrow=c(1,2))
        qqnorm(resid(pH_season))
        acf(resid(pH_season), main="acf(resid(dTA Season))")

        par(mfrow=c(1,1))
  #summ(pH_season, scale = TRUE)
  #plot_summs(pH_season)  
  
  pH_ses.emmc<-emmeans(pH_season, ~Zone*Sub_region*Season)
    pH_ses.emmc<-multcomp::cld(pH_ses.emmc)
    pH_ses.emmc<-as.data.frame(pH_ses.emmc[complete.cases(pH_ses.emmc),])
    pH_ses.emmc<-pH_ses.emmc[order(pH_ses.emmc$Zone, pH_ses.emmc$Season), ]
  pH_ses.emmc
  pH_ses.emmc<-emmeans(pH_season, ~Zone, by = "Sub_region")
    pH_ses.emmc<-multcomp::cld(pH_ses.emmc)
    pH_ses.emmc<-as.data.frame(pH_ses.emmc[complete.cases(pH_ses.emmc),])
    #pH_ses.emmc<-pH_ses.emmc[order(pH_ses.emmc$Zone, pH_ses.emmc$Season), ]
  pH_ses.emmc
  pH_ses.emmc<-emmeans(pH_season, ~Zone)
    pH_ses.emmc<-multcomp::cld(pH_ses.emmc)
    pH_ses.emmc<-as.data.frame(pH_ses.emmc[complete.cases(pH_ses.emmc),])
    #pH_ses.emmc<-pH_ses.emmc[order(pH_ses.emmc$Zone, pH_ses.emmc$Season), ]
  pH_ses.emmc

LMER - all dpH - MODEL 15

# Inshore Omega
  hist(season.data$dpH_MY)

  shapiro.test(season.data$dpH_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dpH_MY
## W = 0.94163, p-value < 2.2e-16
  # dpH_season<-lmer(Aragonite_Sat_W~  Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  dpH_season<-lmer(dpH_MY~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dpH_season)    
  av.dpH_season<-anova(dpH_season)
  av.dpH_season
  ranova(dpH_season)
  #step(dpH_season)
  
  plot(dpH_season)

  par(mfrow=c(1,2))
  qqnorm(resid(dpH_season))
  acf(resid(dpH_season), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #plot_summs(dpH_season)  
    
dpH_ses.emmc<-emmeans(dpH_season, ~Zone*Season, by="Sub_region")
    dpH_ses.emmc<-multcomp::cld(dpH_ses.emmc)
    dpH_ses.emmc
dpH_ses.emmc<-emmeans(dpH_season, ~Sub_region)
    dpH_ses.emmc<-multcomp::cld(dpH_ses.emmc)
    dpH_ses.emmc
dpH_ses.emmc2<-emmeans(dpH_season, ~Season*Sub_region, by="Zone")
    dpH_ses.emmc2<-multcomp::cld(dpH_ses.emmc2)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dpH_ses.emmc2<-dpH_ses.emmc2[order(dpH_ses.emmc2$Zone, 
                                     dpH_ses.emmc2$Season, 
                                     dpH_ses.emmc2$Sub_region), ]
  #dpH_ses.emmc2

  dpH_ses.emmc2[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                   caption = "Seasonal d pH") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal d pH
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB 0.01 0.01 151.84 -0.01 0.03 1
Winter UK 0.01 0.01 175.85 -0.01 0.03 1
Winter MK 0.01 0.01 156.54 -0.01 0.03 1
Winter LK 0.00 0.01 151.04 -0.01 0.02 1
Spring BB 0.00 0.01 127.01 -0.02 0.02 1
Spring UK 0.00 0.01 146.80 -0.01 0.02 1
Spring MK 0.02 0.01 112.68 0.00 0.03 1
Spring LK 0.00 0.01 109.59 -0.02 0.01 1
Summer BB -0.02 0.01 166.81 -0.04 0.00 1
Summer UK -0.01 0.01 188.96 -0.03 0.01 1
Summer MK -0.01 0.01 166.81 -0.03 0.01 1
Summer LK -0.02 0.01 193.49 -0.04 0.00 1
Fall BB 0.00 0.01 118.10 -0.03 0.02 1
Fall UK 0.00 0.01 147.40 -0.02 0.02 1
Fall MK 0.00 0.01 112.68 -0.02 0.02 1
Fall LK 0.00 0.01 113.88 -0.02 0.01 1
Mid-Channel
Winter BB 0.01 0.01 166.81 -0.01 0.04 123456
Winter UK 0.03 0.01 183.66 0.01 0.05 456
Winter MK 0.02 0.01 156.54 0.00 0.04 3456
Winter LK -0.01 0.01 118.29 -0.03 0.01 12345
Spring BB 0.03 0.01 165.71 0.01 0.05 456
Spring UK 0.04 0.01 151.81 0.02 0.06 56
Spring MK 0.04 0.01 107.36 0.03 0.06 6
Spring LK 0.01 0.01 97.93 0.00 0.03 23456
Summer BB -0.03 0.01 166.81 -0.05 -0.01 123
Summer UK -0.01 0.01 202.38 -0.04 0.01 12345
Summer MK -0.03 0.01 166.81 -0.05 -0.01 12
Summer LK -0.04 0.01 190.14 -0.06 -0.02 1
Fall BB -0.02 0.01 128.09 -0.04 0.00 1234
Fall UK -0.01 0.01 151.81 -0.04 0.01 1234
Fall MK -0.01 0.01 118.56 -0.03 0.01 12345
Fall LK -0.02 0.01 102.53 -0.03 0.00 1234
Inshore
Winter BB 0.02 0.01 151.85 0.00 0.04 456
Winter UK 0.04 0.01 203.00 0.02 0.06 567
Winter MK 0.03 0.01 177.73 0.01 0.05 56
Winter LK -0.01 0.01 130.95 -0.02 0.01 345
Spring BB 0.05 0.01 127.03 0.03 0.07 678
Spring UK 0.10 0.01 166.81 0.08 0.12 8
Spring MK 0.07 0.01 97.93 0.06 0.09 78
Spring LK 0.02 0.01 93.73 0.01 0.04 56
Summer BB -0.06 0.01 166.81 -0.08 -0.04 12
Summer UK -0.03 0.01 166.81 -0.05 -0.01 234
Summer MK -0.05 0.01 166.81 -0.07 -0.03 23
Summer LK -0.11 0.01 204.28 -0.13 -0.09 1
Fall BB -0.05 0.01 109.95 -0.07 -0.03 23
Fall UK -0.06 0.01 166.81 -0.08 -0.04 2
Fall MK -0.03 0.01 118.27 -0.05 -0.01 234
Fall LK -0.06 0.01 102.53 -0.07 -0.04 2
  dpH_year.emmc<-emmeans(dpH_season, ~Sub_region*Zone)
    dpH_year.emmc<-multcomp::cld(dpH_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dpH_year.emmc<-dpH_year.emmc[order(dpH_year.emmc$Zone, 
                                      dpH_year.emmc$Sub_region), ]
  #dDIC_year.emmc
  
  dpH_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year d pH") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year d pH
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB 0.00 0.01 20.97 -0.02 0.01 2
UK 0.00 0.01 23.62 -0.01 0.01 2
MK 0.00 0.01 20.50 -0.01 0.02 2
LK -0.01 0.00 21.00 -0.02 0.00 2
Mid-Channel
BB 0.00 0.01 22.69 -0.02 0.01 2
UK 0.01 0.01 24.39 0.00 0.03 2
MK 0.01 0.01 20.51 -0.01 0.02 2
LK -0.01 0.01 19.34 -0.03 0.00 12
Inshore
BB -0.01 0.01 20.73 -0.02 0.00 12
UK 0.01 0.01 24.76 0.00 0.02 2
MK 0.01 0.01 20.76 0.00 0.02 2
LK -0.04 0.01 19.89 -0.05 -0.03 1

Figure 4C: Model

dpH_ses_2.emmc<-as.data.frame(dpH_ses.emmc2)
dpH_ye_3.emmc<-as.data.frame(dpH_year.emmc)
dpH_ye_3.emmc$Season<-"Mean"

dpH_all_4<-rbind(dpH_ses_2.emmc, dpH_ye_3.emmc)
dpH_all_4$Zone<-factor(dDIC_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearpH<- ggplot(dpH_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.01, 0.01),
                     breaks = seq(-6, 6, 0.05),
                     name=(expression (paste(Delta ,
                          ~pH[]))))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 

DeltaYearpH

LMER - pH Inshore

# Inshore pH
  hist(inshore.season.data$pH_calculated)

  shapiro.test(inshore.season.data$pH_calculated) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$pH_calculated
## W = 0.99362, p-value = 0.09003
  pH_season_in<-lmer(pH_calculated~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
    #summary(pH_season_in)    
    av.pH_season_in<-anova(pH_season_in)
    av.pH_season_in
    ranova(pH_season_in)
    #step(pH_season_in)
    
    plot(pH_season_in)

    par(mfrow=c(1,2))
    qqnorm(resid(pH_season_in))
    acf(resid(pH_season_in), main="acf(resid(dTA Season))")

    par(mfrow=c(1,1))
    #summ(pH_season_in, scale = TRUE)
    #plot_summs(pH_season_in)
  
  pH_ses_in.emmc<-emmeans(pH_season_in, ~ Sub_region*Season)
    pH_ses_in.emmc<-multcomp::cld(pH_ses_in.emmc)
    #pH_ses_in.emmc<-as.data.frame(pH_ses_in.emmc[complete.cases(pH_ses_in.emmc),])
    pH_ses_in.emmc<-pH_ses_in.emmc[order(pH_ses_in.emmc$Season,
                                           pH_ses_in.emmc$Sub_region), ]
  pH_ses_in.emmc

Summary all data

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.dTA_season <- data.frame(av.dTA_season)
    av.dDIC_season <- data.frame(av.dDIC_season) 
    av.dPCO2_season <- data.frame(av.dPCO2_season)
    av.dOme_season <- data.frame(av.dOme_season) 
    av.dpH_season <- data.frame(av.dpH_season) 
    
    # Putting all into one dataframe/table
    anova_results_all <- data.frame(cbind
                    (c("Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season"), 
                                      rbind(av.dTA_season, av.dDIC_season, av.dPCO2_season,
                                            av.dOme_season, av.dpH_season ))) 
    colnames(anova_results_all) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_results_all) <- NULL
    
    # create HTML table using kableExtra
    anova_results_all %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "d TA", 1, 7) %>% # groups rows with label
      pack_rows(., "d DIC", 8, 14)  %>% # groups rows with label
      pack_rows(., "d pCO2", 15, 21) %>% # groups rows with label
      pack_rows(., "d Omega", 22, 28)  %>% # groups rows with label
      pack_rows(., "d pH", 29, 35)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
d TA
Zone 139072.57 69536.29 2 24.20 29.62 0.00
Sub_region 246323.49 82107.83 3 23.96 34.97 0.00
Season 908826.72 302942.24 3 1122.74 129.03 0.00
Zone:Sub_region 195949.68 32658.28 6 23.96 13.91 0.00
Zone:Season 620796.81 103466.13 6 1122.75 44.07 0.00
Sub_region:Season 184979.93 20553.33 9 1122.69 8.75 0.00
Zone:Sub_region:Season 104162.16 5786.79 18 1122.70 2.46 0.00
d DIC
Zone 50700.33 25350.16 2 23.61 10.53 0.00
Sub_region 88482.32 29494.11 3 23.46 12.25 0.00
Season 1412579.92 470859.97 3 1116.17 195.55 0.00
Zone:Sub_region 67333.95 11222.33 6 23.46 4.66 0.00
Zone:Season 1041238.03 173539.67 6 1116.18 72.07 0.00
Sub_region:Season 193626.44 21514.05 9 1116.14 8.93 0.00
Zone:Sub_region:Season 115256.36 6403.13 18 1116.15 2.66 0.00
d pCO2
Zone 21292.59 10646.30 2 22.35 3.68 0.04
Sub_region 77914.85 25971.62 3 22.23 8.99 0.00
Season 1180943.62 393647.87 3 1113.12 136.19 0.00
Zone:Sub_region 25533.07 4255.51 6 22.23 1.47 0.23
Zone:Season 644262.40 107377.07 6 1113.12 37.15 0.00
Sub_region:Season 77749.05 8638.78 9 1113.08 2.99 0.00
Zone:Sub_region:Season 83813.71 4656.32 18 1113.09 1.61 0.05
d Omega
Zone 2.45 1.22 2 21.82 14.27 0.00
Sub_region 7.33 2.44 3 21.66 28.51 0.00
Season 37.55 12.52 3 1112.87 146.08 0.00
Zone:Sub_region 3.23 0.54 6 21.66 6.28 0.00
Zone:Season 20.93 3.49 6 1112.87 40.71 0.00
Sub_region:Season 2.65 0.29 9 1112.82 3.43 0.00
Zone:Sub_region:Season 2.10 0.12 18 1112.83 1.36 0.14
d pH
Zone 0.01 0.00 2 22.47 2.03 0.15
Sub_region 0.08 0.03 3 22.35 14.13 0.00
Season 0.82 0.27 3 1113.24 145.85 0.00
Zone:Sub_region 0.03 0.01 6 22.35 2.95 0.03
Zone:Season 0.41 0.07 6 1113.25 36.61 0.00
Sub_region:Season 0.04 0.00 9 1113.20 2.49 0.01
Zone:Sub_region:Season 0.04 0.00 18 1113.21 1.24 0.22
#export_summs(dTA_season, dDIC_season, dpCO2_season,  scale = TRUE)
      
      Seasonal_models<-list("d TA" = dTA_season, 
                         "d DIC" = dDIC_season, 
                         "d pCO2" = dpCO2_season, 
                         "Omega" = Omega_season,
                         "pH" = pH_season)
      
      modelsummary(Seasonal_models, stars = TRUE, 
                   #statistic = c('std.error', 'p.value', 'conf.int'),
                   title = 'Seasonal and spatial models'#,
                   #coef_map=factor_order
                   )
Seasonal and spatial models
d TA d DIC d pCO2 Omega pH
(Intercept) 1.151 −3.288 −12.895 3.699*** 8.074***
(12.343) (12.873) (14.302) (0.072) (0.012)
ZoneMid channel 6.980 11.655 0.967 −0.061 −0.002
(17.700) (18.446) (20.486) (0.103) (0.017)
ZoneInshore 39.538* 48.038** 4.090 −0.082 0.006
(17.456) (18.206) (20.227) (0.102) (0.017)
Sub_regionUK 2.872 0.772 −2.000 −0.009 −0.003
(16.251) (16.932) (18.803) (0.095) (0.016)
Sub_regionMK 3.553 9.035 5.679 −0.057 −0.004
(15.992) (16.676) (18.526) (0.093) (0.015)
Sub_regionLK 0.894 8.565 9.487 −0.110 −0.010
(15.119) (15.645) (17.520) (0.088) (0.015)
SeasonSpring −4.743 0.687 7.803 0.056 −0.036*
(16.179) (16.386) (17.954) (0.090) (0.015)
SeasonSummer −6.663 9.168 38.495* 0.178+ −0.075***
(16.878) (17.093) (18.728) (0.096) (0.016)
SeasonFall −1.989 6.863 17.605 0.059 −0.035*
(15.985) (16.188) (17.736) (0.091) (0.015)
ZoneMid channelSub_regionUK −0.224 −9.855 −15.550 0.120 0.020
(24.409) (25.414) (28.212) (0.142) (0.024)
ZoneInshoreSub_regionUK 5.297 −5.072 −18.754 0.104 0.020
(23.191) (24.150) (26.813) (0.135) (0.022)
ZoneMid channelSub_regionMK 13.647 4.876 −5.943 0.118 0.014
(22.806) (23.769) (26.400) (0.133) (0.022)
ZoneInshoreSub_regionMK 27.249 12.751 −10.947 0.171 0.015
(22.797) (23.761) (26.390) (0.133) (0.022)
ZoneMid channelSub_regionLK 4.600 13.050 20.033 −0.036 −0.007
(21.848) (22.707) (25.328) (0.127) (0.021)
ZoneInshoreSub_regionLK −34.273 −27.317 13.701 −0.070 −0.011
(21.780) (22.642) (25.258) (0.127) (0.021)
ZoneMid channelSeasonSpring −11.628 −33.419 −32.344 0.215+ 0.031
(23.567) (23.869) (26.152) (0.130) (0.022)
ZoneInshoreSeasonSpring −98.252*** −138.416*** −67.862** 0.398** 0.048*
(22.881) (23.174) (25.390) (0.127) (0.021)
ZoneMid channelSeasonSummer −15.249 −13.510 7.990 −0.021 −0.007
(24.049) (24.355) (26.684) (0.136) (0.023)
ZoneInshoreSeasonSummer −80.273*** −64.334** 47.962+ −0.196 −0.047*
(23.870) (24.174) (26.485) (0.135) (0.023)
ZoneMid channelSeasonFall −2.076 6.951 17.990 −0.088 −0.013
(22.931) (23.223) (25.444) (0.130) (0.022)
ZoneInshoreSeasonFall −12.467 21.707 69.908** −0.357** −0.053*
(22.482) (22.768) (24.945) (0.127) (0.021)
Sub_regionUKSeasonSpring −1.044 −1.189 1.093 0.044 0.004
(21.323) (21.599) (23.667) (0.119) (0.020)
Sub_regionMKSeasonSpring −7.038 −22.620 −23.313 0.161 0.019
(20.772) (21.037) (23.050) (0.116) (0.019)
Sub_regionLKSeasonSpring −8.531 −13.936 −3.961 0.079 0.003
(19.669) (19.823) (21.827) (0.110) (0.018)
Sub_regionUKSeasonSummer −2.116 −9.672 −11.879 0.114 0.013
(22.219) (22.502) (24.654) (0.126) (0.021)
Sub_regionMKSeasonSummer −22.759 −35.351 −25.654 0.119 0.015
(21.832) (22.110) (24.225) (0.124) (0.021)
Sub_regionLKSeasonSummer −5.817 −14.086 −11.956 0.102 0.011
(20.673) (21.029) (23.142) (0.118) (0.020)
Sub_regionUKSeasonFall −2.610 −1.630 −2.108 0.012 0.002
(21.166) (21.436) (23.486) (0.120) (0.020)
Sub_regionMKSeasonFall −4.035 −12.220 −12.289 0.085 0.012
(20.621) (20.883) (22.881) (0.117) (0.020)
Sub_regionLKSeasonFall −3.418 −10.961 −11.369 0.114 0.011
(19.542) (19.692) (21.684) (0.111) (0.019)
ZoneMid channelSub_regionUKSeasonSpring 3.961 3.235 7.711 0.047 −0.009
(32.297) (32.713) (35.843) (0.180) (0.030)
ZoneInshoreSub_regionUKSeasonSpring −1.641 −28.321 −22.514 0.260 0.030
(30.433) (30.825) (33.774) (0.169) (0.028)
ZoneMid channelSub_regionMKSeasonSpring −38.880 −35.123 3.087 −0.066 −0.019
(29.873) (30.255) (33.149) (0.166) (0.028)
ZoneInshoreSub_regionMKSeasonSpring −42.020 −38.930 5.364 −0.075 −0.010
(29.401) (29.776) (32.624) (0.164) (0.027)
ZoneMid channelSub_regionLKSeasonSpring −37.312 −40.329 −14.863 −0.022 −0.006
(28.773) (29.075) (31.931) (0.160) (0.027)
ZoneInshoreSub_regionLKSeasonSpring −19.824 −9.394 0.255 −0.173 −0.017
(28.279) (28.573) (31.381) (0.158) (0.026)
ZoneMid channelSub_regionUKSeasonSummer 7.662 11.691 9.931 −0.036 −0.013
(33.339) (33.763) (36.992) (0.189) (0.032)
ZoneInshoreSub_regionUKSeasonSummer 4.962 −1.014 −8.726 0.079 −0.001
(31.437) (31.838) (34.883) (0.178) (0.030)
ZoneMid channelSub_regionMKSeasonSummer −53.959+ −42.507 10.706 −0.163 −0.025
(31.014) (31.409) (34.412) (0.176) (0.029)
ZoneInshoreSub_regionMKSeasonSummer −117.512*** −106.484*** −21.498 −0.239 −0.012
(31.007) (31.402) (34.405) (0.176) (0.029)
ZoneMid channelSub_regionLKSeasonSummer −62.444* −69.360* −17.010 −0.053 −0.005
(29.950) (30.545) (33.537) (0.171) (0.029)
ZoneInshoreSub_regionLKSeasonSummer −110.248*** −64.522* 33.768 −0.364* −0.039
(29.901) (30.581) (33.577) (0.172) (0.029)
ZoneMid channelSub_regionUKSeasonFall −3.477 4.291 14.555 −0.107 −0.017
(31.827) (32.232) (35.315) (0.180) (0.030)
ZoneInshoreSub_regionUKSeasonFall 12.628 28.909 45.400 −0.141 −0.029
(30.127) (30.511) (33.429) (0.171) (0.029)
ZoneMid channelSub_regionMKSeasonFall −10.064 −1.282 4.943 −0.117 −0.013
(29.458) (29.833) (32.686) (0.167) (0.028)
ZoneInshoreSub_regionMKSeasonFall −36.252 −32.676 −16.470 −0.060 0.002
(29.250) (29.622) (32.455) (0.166) (0.028)
ZoneMid channelSub_regionLKSeasonFall −17.802 −27.804 −22.804 0.047 0.010
(28.314) (28.606) (31.417) (0.161) (0.027)
ZoneInshoreSub_regionLKSeasonFall −52.654+ −51.078+ −25.313 −0.086 0.005
(28.052) (28.341) (31.127) (0.159) (0.027)
SD (Intercept SiteID) 5.331 6.933 8.303 0.038 0.006
SD (Observations) 48.454 49.070 53.763 0.275 0.046
Num.Obs. 1188 1182 1180 1195 1195
R2 Marg. 0.504 0.537 0.385 0.452 0.459
R2 Cond. 0.510 0.546 0.399 0.462 0.468
AIC 12342.7 12311.2 12498.3 554.8 −3543.0
BIC 12596.7 12565.0 12752.0 809.0 −3288.7
ICC 0.0 0.0 0.0 0.0 0.0
RMSE 47.33 47.88 52.43 0.27 0.04
+ p
      #modelsummary(Omega_models, estimate = "p.value")

Summary all inshore

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.dTA_season_in <- data.frame(av.dTA_season_in)
    av.dDIC_season_in <- data.frame(av.dDIC_season_in) 
    av.dPCO2_season_in <- data.frame(av.dPCO2_season_in)
    av.Ome_season_in <- data.frame(av.Ome_season_in) 
    av.pH_season_in <- data.frame(av.pH_season_in) 
    
    # Putting all into one dataframe/table
    anova_results_In <- data.frame(cbind
                    (c("Sub_region", "Season", "Sub_region:Season", 
                       
                       "Sub_region", "Season", "Sub_region:Season",
                       
                       "Sub_region", "Season", "Sub_region:Season",
                       
                       "Sub_region", "Season", "Sub_region:Season",
                       
                       "Sub_region", "Season", "Sub_region:Season"), 
                                      rbind(av.dTA_season_in, av.dDIC_season_in,
                                            av.dPCO2_season_in,
                                            av.Ome_season_in, av.pH_season_in))) 
    colnames(anova_results_In) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_results_In) <- NULL
    
    # create HTML table using kableExtra
    anova_results_In %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "d TA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "d DIC inshore", 4, 6)  %>% # groups rows with label
      pack_rows(., "d pCO2 inshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega inshore", 10, 12)  %>% # groups rows with label
      pack_rows(., "pH inshore", 13, 15)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
d TA inshore
Sub_region 423947.51 141315.84 3 8.18 27.43 0.00
Season 1367843.07 455947.69 3 375.41 88.51 0.00
Sub_region:Season 211905.70 23545.08 9 375.40 4.57 0.00
d DIC inshore
Sub_region 125627.20 41875.73 3 7.77 7.82 0.01
Season 2195416.50 731805.50 3 371.98 136.63 0.00
Sub_region:Season 213613.58 23734.84 9 371.97 4.43 0.00
d pCO2 inshore
Sub_region 65733.74 21911.25 3 7.29 3.61 0.07
Season 1552826.95 517608.98 3 371.52 85.23 0.00
Sub_region:Season 133286.22 14809.58 9 371.52 2.44 0.01
Omega inshore
Sub_region 6.21 2.07 3 7.08 14.66 0.00
Season 41.14 13.71 3 377.30 97.02 0.00
Sub_region:Season 3.88 0.43 9 377.30 3.05 0.00
pH inshore
Sub_region 0.08 0.03 3 7.35 6.50 0.02
Season 1.36 0.45 3 377.55 110.52 0.00
Sub_region:Season 0.07 0.01 9 377.55 1.98 0.04
#export_summs(dTA_season, dDIC_season, dpCO2_season,  scale = TRUE)
    Seasonal_models_in<-list("d TA" = dTA_season_in, 
                       "d DIC" = dDIC_season_in, 
                       "d pCO2" = dpCO2_season_in, 
                       "Omega" = Omega_season_in,
                       "pH" = pH_season_in)
    
    modelsummary(Seasonal_models_in, stars = TRUE, 
                 #statistic = c('std.error', 'p.value', 'conf.int'),
                 title = 'Seasonal and spatial models for inshore reefs'#,
                 #coef_map=factor_order
                 )
Seasonal and spatial models for inshore reefs
d TA d DIC d pCO2 Omega pH
(Intercept) 40.707* 44.734* −8.879 3.617*** 8.080***
(18.027) (19.323) (21.388) (0.101) (0.017)
Sub_regionUK 8.168 −4.278 −20.605 0.094 0.017
(24.188) (25.837) (28.527) (0.135) (0.023)
Sub_regionMK 30.816 21.802 −5.139 0.114 0.011
(23.740) (25.399) (28.077) (0.133) (0.023)
Sub_regionLK −33.266 −18.777 23.237 −0.180 −0.021
(22.886) (24.573) (27.232) (0.129) (0.022)
SeasonSpring −102.964*** −137.755*** −60.185* 0.455*** 0.012
(23.965) (24.439) (26.025) (0.123) (0.021)
SeasonSummer −86.954*** −55.150* 86.531** −0.018 −0.122***
(25.001) (25.493) (27.147) (0.131) (0.022)
SeasonFall −14.460 28.573 87.527*** −0.298* −0.088***
(23.416) (23.877) (25.425) (0.123) (0.021)
Sub_regionUKSeasonSpring −2.733 −29.489 −21.370 0.303+ 0.034
(32.162) (32.799) (34.928) (0.164) (0.028)
Sub_regionMKSeasonSpring −49.117 −61.523+ −17.865 0.085 0.009
(30.819) (31.428) (33.467) (0.159) (0.027)
Sub_regionLKSeasonSpring −28.480 −23.279 −3.623 −0.094 −0.013
(30.094) (30.691) (32.684) (0.155) (0.027)
Sub_regionUKSeasonSummer 2.846 −10.707 −20.754 0.194 0.012
(32.941) (33.592) (35.772) (0.173) (0.029)
Sub_regionMKSeasonSummer −140.285*** −141.851*** −47.281 −0.119 0.004
(32.614) (33.257) (35.414) (0.171) (0.029)
Sub_regionLKSeasonSummer −116.177*** −78.583* 21.762 −0.261 −0.028
(31.997) (33.115) (35.264) (0.170) (0.029)
Sub_regionUKSeasonFall 10.005 27.271 43.204 −0.128 −0.027
(31.755) (32.383) (34.483) (0.166) (0.028)
Sub_regionMKSeasonFall −40.303 −44.900 −28.814 0.026 0.013
(30.726) (31.333) (33.365) (0.161) (0.027)
Sub_regionLKSeasonFall −56.199+ −62.002* −36.671 0.028 0.015
(29.809) (30.398) (32.371) (0.156) (0.027)
SD (Intercept SiteID) 6.619 10.789 14.147 0.063 0.010
SD (Observations) 71.772 73.184 77.929 0.376 0.064
Num.Obs. 397 394 394 400 400
R2 Marg. 0.520 0.560 0.422 0.501 0.484
R2 Cond. 0.524 0.569 0.440 0.514 0.497
AIC 4426.5 4409.1 4458.0 430.3 −927.9
BIC 4498.2 4480.6 4529.6 502.2 −856.0
ICC 0.0 0.0 0.0 0.0 0.0
RMSE 70.16 71.39 75.95 0.37 0.06
+ p
    #modelsummary(Omega_models, estimate = "p.value")

Figure 4: Models

Figure_4<-ggarrange(DeltaYearTA+ theme(axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 legend.position = "none"),
                  DeltaYearDIC+ theme(legend.position = "none",
                                 axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 strip.text.x = element_blank()),
                  DeltaYearpH + theme(legend.position = "none",
                                 axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 strip.text.x = element_blank()),
                  DeltaYearAra+ theme(legend.position = "bottom",
                                 strip.text.x = element_blank(),
                                 panel.spacing = unit(0.8, "lines")),
          labels = c("A", "B", "C", "D"),
          ncol = 1, nrow = 4, heights = c(1, 0.9, 0.9, 1.2))
Figure_4

#ggsave(file="FLK_results/Figures/Fig_4/Figure_4.svg", plot=Figure_4, dpi = 300, width=8, height=7)

6 LMER long trend MODELS

  • The F statistic in a regression model is used to test whether there is a linear model of the data - overall , or equivalently that your model is no better than a model with just the intercept.

  • The t statistic for a coefficient in a linear model tests the H0 that the true coefficient is 0.

*The t-statistic is telling you about each coefficient individually. You can have a model with a low overall linear fit, but one individual coefficient may be relatively contributing a lot to explanation the variation in the DV that is explained on the assumption that there is a linear model.

Data and plots prep

Trends.data<-FLK.data_filtered[FLK.data_filtered$Year>2014, ]
#summary(Trends.data)

Reef.Trends.data<-WS.reef[WS.reef$Year>2014, ]
Reef.Trends.data<-Reef.Trends.data[Reef.Trends.data$Extreme=="Normal", ]
#summary(Reef.Trends.data$Extreme)

Trends.ocean<-Trends.data[Trends.data$Zone=="Oceanic", ]

Trends.offshore<-Reef.Trends.data[Reef.Trends.data$Zone=="Offshore", ]
Trends.midchanel<-Reef.Trends.data[Reef.Trends.data$Zone=="Mid channel", ]
Trends.inshore<-Reef.Trends.data[Reef.Trends.data$Zone=="Inshore", ]

Long_plot<- ggplot(Trends.data) +
        MyTheme +  
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank())+
        scale_x_date(date_breaks = "2 years",
                     date_labels = "%Y",
                     expand = c(0.02, 0.02))

Long_plot2<- ggplot() +
        MyTheme +  
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank(),
                axis.text.x = element_text(angle = 0, vjust = 0.5))+
        scale_x_date(date_breaks = "2 years",
                     date_labels = "%Y",
                     expand = c(0.02, 0.02))
xs <- as.Date(as.character("2018-11-20"))

factor_order <- c('Year'    = 'Year',
                  '(Intercept)' = 'Intercept',
                  'Sub_regionUK'    = 'Upper Keys',
                  'Sub_regionMK'    = 'Middle Keys',
                  'Sub_regionLK'    = 'Lower Keys')

Temperature-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$Aragonite_Sat_W
## W = 0.96676, p-value = 5.771e-16

## Model with all data
Temo_all_o<-lmer(Temperature_C~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
  step(Temo_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    33 -1987.6 4041.3                         
## (1 | SiteID)          1   32 -1987.6 4039.3    0.0  1          1    
## (1 | Month)           0   31 -3002.9 6067.9 2030.6  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Zone:Sub_region          1  4.4825  0.5603     8 1174.1  0.4030 0.9192438
## Zone:Sub_region               2  5.5939  0.6992     8 1182.0  0.5050 0.8531967
## Year:Sub_region               3  7.0805  2.3602     3 1190.1  1.7102 0.1630923
## Year:Zone                     4  8.2475  2.7492     3 1193.0  1.9885 0.1139083
## Year                          0 10.2765 10.2765     1 1199.3  7.4149 0.0065625
## Zone                          0 26.2549  8.7516     3 1196.0  6.3146 0.0003002
## Sub_region                    0 12.0698  4.0233     3 1196.0  2.9029 0.0338495
##                         
## Year:Zone:Sub_region    
## Zone:Sub_region         
## Year:Sub_region         
## Year:Zone               
## Year                 ** 
## Zone                 ***
## Sub_region           *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Temperature_C ~ Year + Zone + Sub_region + (1 | Month)
Temp_all_1<-lmer(Temperature_C ~ Year + Zone + (1 | Month) +
                      Year:Zone, data=Trends.data)

anova(Temp_all_1, Temo_all_o)
    summary(Temp_all_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ Year + Zone + (1 | Month) + Year:Zone
##    Data: Trends.data
## 
## REML criterion at convergence: 3942.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -7.4420 -0.5244 -0.0323  0.4733  3.4069 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 8.621    2.936   
##  Residual             1.389    1.179   
## Number of obs: 1215, groups:  Month, 12
## 
## Fixed effects:
##                        Estimate Std. Error         df t value Pr(>|t|)  
## (Intercept)           3.538e+01  6.689e+01  1.198e+03   0.529   0.5970  
## Year                 -4.169e-03  3.315e-02  1.197e+03  -0.126   0.8999  
## ZoneMid channel      -1.385e+02  8.810e+01  1.196e+03  -1.572   0.1161  
## ZoneOffshore         -1.848e+02  8.383e+01  1.196e+03  -2.204   0.0277 *
## ZoneOceanic          -2.060e+02  1.100e+02  1.196e+03  -1.874   0.0612 .
## Year:ZoneMid channel  6.877e-02  4.366e-02  1.196e+03   1.575   0.1155  
## Year:ZoneOffshore     9.171e-02  4.155e-02  1.196e+03   2.207   0.0275 *
## Year:ZoneOceanic      1.023e-01  5.450e-02  1.196e+03   1.877   0.0607 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   ZnMdch ZnOffs ZnOcnc Yr:ZMc Yr:ZnOf
## Year        -1.000                                           
## ZoneMdchnnl -0.634  0.634                                    
## ZoneOffshor -0.667  0.667  0.505                             
## ZoneOceanic -0.509  0.509  0.385  0.405                      
## Yr:ZnMdchnn  0.634 -0.634 -1.000 -0.505 -0.385               
## Yr:ZnOffshr  0.667 -0.667 -0.505 -1.000 -0.405  0.505        
## Year:ZnOcnc  0.509 -0.509 -0.385 -0.405 -1.000  0.385  0.405
    anova(Temp_all_1)
    ranova(Temp_all_1)
# Obtain slopes
    #ranef(Temp_all_1)
    #fixef(Temp_all_1)
    #coef(Temp_all_1)$Month
    #coef(Temp_all_1)$Zone
  m.lst <- lstrends(Temp_all_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend     SE   df lower.CL upper.CL
##  Inshore       -0.00417 0.0332 1197 -0.06921   0.0609
##  Mid channel    0.06460 0.0342 1197 -0.00255   0.1317
##  Offshore       0.08754 0.0314 1198  0.02589   0.1492
##  Oceanic        0.09814 0.0472 1197  0.00553   0.1908
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate     SE   df t.ratio p.value
##  Inshore - Mid channel   -0.0688 0.0437 1196  -1.575  0.3933
##  Inshore - Offshore      -0.0917 0.0415 1196  -2.207  0.1218
##  Inshore - Oceanic       -0.1023 0.0545 1196  -1.877  0.2383
##  Mid channel - Offshore  -0.0229 0.0424 1196  -0.541  0.9490
##  Mid channel - Oceanic   -0.0335 0.0552 1196  -0.608  0.9295
##  Offshore - Oceanic      -0.0106 0.0535 1196  -0.198  0.9972
## 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore

# Inshore Omega
  hist(Trends.inshore$Temperature_C)

  shapiro.test(Trends.inshore$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$Aragonite_Sat_W
## W = 0.99052, p-value = 0.02452
  Temp_in_0<-lmer(Temperature_C~Year * Sub_region + (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  #summary(Omega_in_0)
  #summary(Omega_in_1)    
  #anova(Omega_in_0, Omega_in_1)
  #step(Omega_in_1)
  
  anova(Temp_in_0)
  ranova(Temp_in_0)
  step(Temp_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -654.60 1331.2                         
## (1 | SiteID)          1   10 -654.60 1329.2   0.00  1     0.9999    
## (1 | Month)           0    9 -933.69 1885.4 558.18  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1 6.8641 2.28804     3 330.98  1.1298 0.3370
## Year                     2 0.7414 0.74144     1 337.33  0.3657 0.5458
## Sub_region               3 7.9865 2.66217     3 335.00  1.3150 0.2694
## 
## Model found:
## Temperature_C ~ (1 | Month)
  Temp_in<-lmer(Temperature_C ~ (1 | Month),
                 data=Trends.inshore)
  ranova(Temp_in)
  summary(Temp_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 1299.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -6.1768 -0.4944  0.0139  0.5596  2.7909 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 12.05    3.471   
##  Residual              2.03    1.425   
## Number of obs: 350, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   26.970      1.005 10.976   26.83 2.33e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(Temp_in)

  qqnorm(resid(Temp_in))

  acf(resid(Temp_in), main="acf(resid(Temperature Inshore))")

Mid channel

hist(Trends.midchanel$Temperature_C)

shapiro.test(Trends.midchanel$Temperature_C)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$Temperature_C
## W = 0.97341, p-value = 1.19e-05
Temp_mc_0<-lmer(Temperature_C~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)

anova(Temp_mc_0)
ranova(Temp_mc_0)
step(Temp_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -507.18 1036.4                         
## (1 | SiteID)          1   10 -507.18 1034.4   0.00  1          1    
## (1 | Month)           0    9 -794.85 1607.7 575.34  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1 1.0153  0.3384     3 301.95  0.3102 0.81802  
## Sub_region               2 4.3399  1.4466     3 304.98  1.3350 0.26306  
## Year                     3 3.2073  3.2073     1 310.48  2.9501 0.08687 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Temperature_C ~ (1 | Month)
Temp_mc<-lmer(Temperature_C ~ (1 | Month),
               data = Trends.midchanel)
  summary(Temp_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 1001.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.0547 -0.5463 -0.0556  0.5019  2.7801 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 8.549    2.924   
##  Residual             1.095    1.047   
## Number of obs: 321, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  27.2421     0.8463 10.9775   32.19 3.23e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(Temp_mc)

  qqnorm(resid(Temp_mc))

  acf(resid(Temp_mc), main="acf(resid(Omega mid Channel))")

Offshore

hist(Trends.offshore$Temperature_C)

shapiro.test(Trends.offshore$Temperature_C)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$Temperature_C
## W = 0.96684, p-value = 8.65e-08
Temp_of_0<-lmer(Temperature_C~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
#summary(Omega_of_0)    
anova(Temp_of_0)
ranova(Temp_of_0)
step(Temp_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -490.60 1003.2                         
## (1 | SiteID)          1   10 -490.60 1001.2   0.00  1          1    
## (1 | Month)           0    9 -906.96 1831.9 832.71  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1 2.0849  0.6950     3 374.98  1.2340 0.297079   
## Sub_region               2 3.1704  1.0568     3 377.98  1.8731 0.133631   
## Year                     0 4.4221  4.4221     1 382.67  7.7841 0.005535 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Temperature_C ~ Year + (1 | Month)
Temp_of<-lmer(Temperature_C ~ (1 | Month), 
               data =Trends.offshore)
  summary(Temp_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 971.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.2993 -0.6222 -0.0863  0.4675  3.2857 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6.7781   2.6035  
##  Residual             0.5789   0.7608  
## Number of obs: 394, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  27.2617     0.7527 10.9783   36.22 8.92e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(Temp_of)

  qqnorm(resid(Temp_of))

  acf(resid(Temp_of), main="acf(resid(Omega offshore))")  

Oceanic

hist(Trends.ocean$Temperature_C)

shapiro.test(Trends.ocean$Temperature_C)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$Temperature_C
## W = 0.94994, p-value = 3.237e-05
Temp_oc_0<-lmer(Temperature_C ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)

  anova(Temp_oc_0)
  ranova(Temp_oc_0)
  step(Temp_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -200.71 419.41                         
## (1 | SiteID)          1    8 -200.71 417.41   0.00  1          1    
## (1 | Month)           0    7 -333.67 681.34 265.93  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1 0.38013 0.19006     2 132.95  0.3494 0.7058
## Sub_region               2 0.10411 0.05206     2 134.95  0.0966 0.9079
## Year                     3 0.58493 0.58493     1 138.67  1.1004 0.2960
## 
## Model found:
## Temperature_C ~ (1 | Month)
Temp_oc<-lmer(Temperature_C ~(1 | Month), data = Trends.ocean)
  summary(Temp_oc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Temperature_C ~ (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 387.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.2201 -0.5860 -0.1590  0.5806  2.9776 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 5.7367   2.3951  
##  Residual             0.5331   0.7301  
## Number of obs: 150, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  27.3845     0.6943 10.9427   39.44 3.79e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  ranova(Temp_oc)
  plot(Temp_oc)

  qqnorm(resid(Temp_oc))

  acf(resid(Temp_oc), main="acf(resid(Temp_oc open))")

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.Temp_in_0 <- data.frame (anova(Temp_in_0))
    av.Temp_mc_0 <- data.frame (anova(Temp_mc_0) )
    av.Temp_of_0 <- data.frame (anova(Temp_of_0))
    av.Temp_oc_0 <- data.frame (anova(Temp_oc_0))
    
    # Putting all into one dataframe/table
    anova_Temp_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.Temp_in_0, av.Temp_mc_0,
                                            av.Temp_of_0, av.Temp_oc_0))) 
    colnames(anova_Temp_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_Temp_0) <- NULL
    
    # create HTML table using kableExtra
    anova_Temp_0 %>% kable("html", digits=2, 
        caption="Initial temperature models fixed factors: Year*Region") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
Initial temperature models fixed factors: Year*Region
Sum Sq Mean Sq N Df D Df F value Pr(>F)
Omega inshore
Year 1.11 1.11 1 334.28 0.55 0.46
Sub_region 6.86 2.29 3 331.01 1.13 0.34
Year:Sub_region 6.86 2.29 3 331.01 1.13 0.34
Omega mid-channel
Year 3.22 3.22 1 304.38 2.95 0.09
Sub_region 1.02 0.34 3 301.99 0.31 0.82
Year:Sub_region 1.02 0.34 3 301.99 0.31 0.82
Omega offshore
Year 5.35 5.35 1 376.55 9.51 0.00
Sub_region 2.08 0.69 3 374.95 1.23 0.30
Year:Sub_region 2.08 0.69 3 374.95 1.23 0.30
Omega ocean
Year 0.33 0.33 1 134.54 0.61 0.44
Sub_region 0.38 0.19 2 132.94 0.35 0.71
Year:Sub_region 0.38 0.19 2 132.94 0.35 0.71
# R-ANOVAs    
    rav.Temp_in_0 <- data.frame (ranova(Temp_in_0))
    rav.Temp_mc_0 <- data.frame (ranova(Temp_mc_0) )
    rav.Temp_of_0 <- data.frame (ranova(Temp_of_0))
    rav.Temp_oc_0 <- data.frame (ranova(Temp_oc_0))
    
    # Putting all into one dataframe/table
    ranova_Temp_0 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.Temp_in_0, rav.Temp_mc_0,
                            rav.Temp_of_0, rav.Temp_oc_0))) 
    colnames(ranova_Temp_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_Temp_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_Temp_0 %>% kable("html", digits=2,
         caption="Initial temperature models random factors: Month+Station") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
Initial temperature models random factors: Month+Station
npar logLik AIC LRT DF Pr(>Chi Sq)
Omega inshore
<none> 11 -654.60 1331.20
(1 | Month) 10 -933.69 1887.37 558.18 1 0
(1 | SiteID) 10 -654.60 1329.20 0.00 1 1
Omega mid-channel
<none> 11 -507.18 1036.36
(1 | Month) 10 -794.85 1609.70 575.34 1 0
(1 | SiteID) 10 -507.18 1034.36 0.00 1 1
Omega offshore
<none> 11 -490.60 1003.21
(1 | Month) 10 -906.96 1833.91 832.71 1 0
(1 | SiteID) 10 -490.60 1001.21 0.00 1 1
Omega ocean
<none> 9 -200.71 419.41
(1 | Month) 8 -333.67 683.34 265.93 1 0
(1 | SiteID) 8 -200.71 417.41 0.00 1 1
Temp_models_0<-list("Inshore" = Temp_in_0, 
                   "Mid channel" = Temp_mc_0, 
                   "Offshore" = Temp_of_0, 
                   "Ocean" = Temp_oc_0)
modelsummary(Temp_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Initial temperature model outputs (all factors)',
             coef_map=factor_order)
Initial temperature model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year 0.107 0.091 0.133** −0.008
(0.088) (0.066) (0.047) (0.071)
Intercept −189.516 −157.210 −241.064* 44.111
(177.456) (132.483) (94.175) (143.502)
Upper Keys 52.599 86.321 133.838
(224.188) (181.010) (116.203)
Middle Keys 171.794 12.996 134.123 −95.121
(217.328) (160.231) (115.108) (161.560)
Lower Keys 355.325 128.530 209.830+ −136.534
(217.558) (161.091) (109.249) (163.272)
Num.Obs. 350 321 394 150
R2 Marg. 0.022 0.030 0.053 0.018
R2 Cond.
AIC 1331.2 1036.4 1003.2 419.4
BIC 1373.6 1077.8 1046.9 446.5
RMSE 1.38 1.01 0.73 0.69
+ p
#modelsummary(Omega_models, estimate = "p.value")

Models with non-significant factors removed

Temp_models<-list("Inshore" = Temp_in, 
                   "Mid channel" = Temp_mc, 
                   "Offshore" = Temp_of, 
                   "Ocean" = Temp_oc)
modelsummary(Temp_models, stars = TRUE, 
            #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Final Omega model outputs (dropped factors)',
             coef_map=factor_order)
Final Omega model outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Intercept 26.970*** 27.242*** 27.262*** 27.385***
(1.005) (0.846) (0.753) (0.694)
Num.Obs. 350 321 394 150
R2 Marg. 0.000 0.000 0.000 0.000
R2 Cond. 0.856 0.886 0.921 0.915
AIC 1305.6 1007.2 977.3 393.5
BIC 1317.2 1018.5 989.2 402.5
ICC 0.9 0.9 0.9 0.9
RMSE 1.40 1.03 0.75 0.70
+ p
#modelsummary(Temp_models, estimate = "p.value")

DIC-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$DIC_umol_kg
## W = 0.88724, p-value < 2.2e-16

## Model with all data
DIC_all_o<-lmer(DIC_umol_kg~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
  step(DIC_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC    LRT Df Pr(>Chisq)    
## <none>                    33 -6506.4 13079                         
## (1 | Month)           0   32 -6691.6 13447 370.46  1    < 2e-16 ***
## (1 | SiteID)          0   32 -6507.9 13080   2.92  1    0.08736 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated Sum Sq Mean Sq NumDF   DenDF F value  Pr(>F)  
## Year:Zone:Sub_region          1  11984  1498.0     8 1141.73  0.4676 0.87941  
## Year:Zone                     2   2028   676.1     3 1149.64  0.2118 0.88823  
## Year:Sub_region               0  28636  9545.3     3 1152.78  2.9970 0.02983 *
## Zone:Sub_region               0  75555  9444.4     8   24.31  2.9653 0.01829 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Zone + Sub_region + (1 | Month) + (1 | SiteID) + Year:Sub_region + Zone:Sub_region
DIC_all_1<-lmer(DIC_umol_kg ~ Year + Zone + Sub_region + 
                  (1 | Month) + (1 | SiteID) + 
                  Year:Sub_region + Zone:Sub_region, data=Trends.data)

    summary(DIC_all_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Zone + Sub_region + (1 | Month) + (1 | SiteID) +  
##     Year:Sub_region + Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: 13067.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.5099 -0.4884 -0.0112  0.5678  6.5473 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  SiteID   (Intercept)   60.09   7.752  
##  Month    (Intercept) 1578.89  39.735  
##  Residual             3184.94  56.435  
## Number of obs: 1204, groups:  SiteID, 38; Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                   3353.3045  4055.3416  1160.1473   0.827 0.408472
## Year                            -0.6446     2.0097  1160.1249  -0.321 0.748468
## ZoneMid channel                 -3.7666    12.5161    22.6641  -0.301 0.766204
## ZoneOffshore                    -3.2952    12.4859    22.4488  -0.264 0.794255
## ZoneOceanic                     62.8678    11.6646    24.5997   5.390 1.44e-05
## Sub_regionUK                  3869.6370  5098.3143  1153.1660   0.759 0.448006
## Sub_regionMK                 -7720.1396  4801.3446  1151.9184  -1.608 0.108128
## Sub_regionLK                  2294.5076  4769.8674  1152.0710   0.481 0.630578
## Year:Sub_regionUK               -1.9277     2.5267  1153.1592  -0.763 0.445656
## Year:Sub_regionMK                3.8024     2.3794  1151.9066   1.598 0.110305
## Year:Sub_regionLK               -1.1709     2.3638  1152.0599  -0.495 0.620461
## ZoneMid channel:Sub_regionUK    11.0869    17.2789    24.3678   0.642 0.527096
## ZoneOffshore:Sub_regionUK       15.3582    16.3369    23.6156   0.940 0.356686
## ZoneOceanic:Sub_regionUK       -52.7240    19.3741    27.6910  -2.721 0.011109
## ZoneMid channel:Sub_regionMK    25.0072    16.2207    23.0145   1.542 0.136790
## ZoneOffshore:Sub_regionMK       38.7518    16.1872    22.8264   2.394 0.025282
## ZoneOceanic:Sub_regionMK       -18.6541    16.4642    24.4183  -1.133 0.268215
## ZoneMid channel:Sub_regionLK    42.4505    16.1786    22.7731   2.624 0.015247
## ZoneOffshore:Sub_regionLK       65.1182    15.7412    22.6121   4.137 0.000412
##                                 
## (Intercept)                     
## Year                            
## ZoneMid channel                 
## ZoneOffshore                    
## ZoneOceanic                  ***
## Sub_regionUK                    
## Sub_regionMK                    
## Sub_regionLK                    
## Year:Sub_regionUK               
## Year:Sub_regionMK               
## Year:Sub_regionLK               
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK       
## ZoneOceanic:Sub_regionUK     *  
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK    *  
## ZoneOceanic:Sub_regionMK        
## ZoneMid channel:Sub_regionLK *  
## ZoneOffshore:Sub_regionLK    ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(DIC_all_1)
    ranova(DIC_all_1)
# Obtain slopes
#     ranef(DIC_all_1)
#     fixef(DIC_all_1)
#     coef(DIC_all_1)$Month
#     coef(DIC_all_1)$Zone
    
  m.lst <- lstrends(DIC_all_1, "Sub_region", var="Year")
  m.lst
##  Sub_region Year.trend   SE   df lower.CL upper.CL
##  BB             -0.645 2.01 1159   -4.591    3.302
##  UK             -2.572 1.77 1164   -6.049    0.904
##  MK              3.158 1.55 1162    0.115    6.201
##  LK             -1.815 1.54 1163   -4.834    1.203
## 
## Results are averaged over the levels of: Zone 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  #pairs(m.lst)

Inshore

# Inshore DIC
  hist(Trends.inshore$DIC_umol_kg)

  shapiro.test(Trends.inshore$DIC_umol_kg) # Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$DIC_umol_kg
## W = 0.99654, p-value = 0.66
  DIC_in_0<-lmer(DIC_umol_kg~Year * Sub_region + (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  DIC_in_1<-lmer(DIC_umol_kg~Year * Sub_region * Season +
                                    (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  summary(DIC_in_0)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year * Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3951.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0197 -0.5938 -0.0006  0.6369  4.2110 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 7114.2   84.35   
##  SiteID   (Intercept)  253.5   15.92   
##  Residual             5223.8   72.28   
## Number of obs: 347, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##                     Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)         5059.086   8991.623    325.116   0.563    0.574
## Year                  -1.489      4.456    325.110  -0.334    0.739
## Sub_regionUK        2656.414  11390.728    321.591   0.233    0.816
## Sub_regionMK      -16751.972  11039.360    321.282  -1.517    0.130
## Sub_regionLK        2257.089  11122.331    321.380   0.203    0.839
## Year:Sub_regionUK     -1.325      5.645    321.591  -0.235    0.815
## Year:Sub_regionMK      8.279      5.471    321.280   1.513    0.131
## Year:Sub_regionLK     -1.154      5.512    321.378  -0.209    0.834
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK Sb_rLK Y:S_UK Y:S_MK
## Year        -1.000                                          
## Sub_reginUK -0.700  0.700                                   
## Sub_reginMK -0.723  0.723  0.569                            
## Sub_reginLK -0.710  0.710  0.563  0.581                     
## Yr:Sb_rgnUK  0.700 -0.700 -1.000 -0.569 -0.563              
## Yr:Sb_rgnMK  0.723 -0.723 -0.569 -1.000 -0.581  0.569       
## Yr:Sb_rgnLK  0.710 -0.710 -0.563 -0.581 -1.000  0.563  0.581
  summary(DIC_in_1)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year * Sub_region * Season + (1 | Month) + (1 |  
##     SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3692.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0473 -0.5931 -0.0299  0.5879  4.0020 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  751.6   27.42   
##  SiteID   (Intercept)  232.7   15.25   
##  Residual             4647.1   68.17   
## Number of obs: 347, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##                                  Estimate Std. Error         df t value
## (Intercept)                     5.816e+03  2.150e+04  2.888e+02   0.270
## Year                           -1.839e+00  1.066e+01  2.889e+02  -0.173
## Sub_regionUK                   -1.721e+04  2.721e+04  3.023e+02  -0.633
## Sub_regionMK                   -2.634e+04  2.626e+04  3.004e+02  -1.003
## Sub_regionLK                    1.306e+04  2.617e+04  3.007e+02   0.499
## SeasonSpring                   -2.917e+04  2.637e+04  3.033e+02  -1.106
## SeasonSummer                    1.524e+04  2.731e+04  3.013e+02   0.558
## SeasonFall                      2.080e+04  2.714e+04  2.835e+02   0.766
## Year:Sub_regionUK               8.528e+00  1.348e+01  3.023e+02   0.632
## Year:Sub_regionMK               1.307e+01  1.302e+01  3.004e+02   1.004
## Year:Sub_regionLK              -6.490e+00  1.297e+01  3.007e+02  -0.500
## Year:SeasonSpring               1.438e+01  1.307e+01  3.033e+02   1.101
## Year:SeasonSummer              -7.596e+00  1.354e+01  3.013e+02  -0.561
## Year:SeasonFall                -1.030e+01  1.345e+01  2.835e+02  -0.766
## Sub_regionUK:SeasonSpring       4.134e+04  3.346e+04  3.019e+02   1.235
## Sub_regionMK:SeasonSpring       4.831e+04  3.270e+04  3.006e+02   1.477
## Sub_regionLK:SeasonSpring      -1.411e+04  3.287e+04  3.011e+02  -0.429
## Sub_regionUK:SeasonSummer       1.386e+03  3.441e+04  3.019e+02   0.040
## Sub_regionMK:SeasonSummer       6.958e+03  3.367e+04  3.007e+02   0.207
## Sub_regionLK:SeasonSummer      -1.834e+04  3.463e+04  3.027e+02  -0.529
## Sub_regionUK:SeasonFall         3.896e+04  3.503e+04  3.021e+02   1.112
## Sub_regionMK:SeasonFall        -1.939e+03  3.312e+04  3.007e+02  -0.059
## Sub_regionLK:SeasonFall        -5.540e+03  3.287e+04  3.007e+02  -0.169
## Year:Sub_regionUK:SeasonSpring -2.051e+01  1.658e+01  3.019e+02  -1.237
## Year:Sub_regionMK:SeasonSpring -2.398e+01  1.620e+01  3.006e+02  -1.480
## Year:Sub_regionLK:SeasonSpring  6.980e+00  1.629e+01  3.011e+02   0.429
## Year:Sub_regionUK:SeasonSummer -6.894e-01  1.706e+01  3.019e+02  -0.040
## Year:Sub_regionMK:SeasonSummer -3.518e+00  1.669e+01  3.007e+02  -0.211
## Year:Sub_regionLK:SeasonSummer  9.052e+00  1.717e+01  3.027e+02   0.527
## Year:Sub_regionUK:SeasonFall   -1.931e+01  1.736e+01  3.021e+02  -1.112
## Year:Sub_regionMK:SeasonFall    9.310e-01  1.641e+01  3.007e+02   0.057
## Year:Sub_regionLK:SeasonFall    2.715e+00  1.629e+01  3.007e+02   0.167
##                                Pr(>|t|)
## (Intercept)                       0.787
## Year                              0.863
## Sub_regionUK                      0.527
## Sub_regionMK                      0.317
## Sub_regionLK                      0.618
## SeasonSpring                      0.270
## SeasonSummer                      0.577
## SeasonFall                        0.444
## Year:Sub_regionUK                 0.528
## Year:Sub_regionMK                 0.316
## Year:Sub_regionLK                 0.617
## Year:SeasonSpring                 0.272
## Year:SeasonSummer                 0.575
## Year:SeasonFall                   0.445
## Sub_regionUK:SeasonSpring         0.218
## Sub_regionMK:SeasonSpring         0.141
## Sub_regionLK:SeasonSpring         0.668
## Sub_regionUK:SeasonSummer         0.968
## Sub_regionMK:SeasonSummer         0.836
## Sub_regionLK:SeasonSummer         0.597
## Sub_regionUK:SeasonFall           0.267
## Sub_regionMK:SeasonFall           0.953
## Sub_regionLK:SeasonFall           0.866
## Year:Sub_regionUK:SeasonSpring    0.217
## Year:Sub_regionMK:SeasonSpring    0.140
## Year:Sub_regionLK:SeasonSpring    0.669
## Year:Sub_regionUK:SeasonSummer    0.968
## Year:Sub_regionMK:SeasonSummer    0.833
## Year:Sub_regionLK:SeasonSummer    0.598
## Year:Sub_regionUK:SeasonFall      0.267
## Year:Sub_regionMK:SeasonFall      0.955
## Year:Sub_regionLK:SeasonFall      0.868
  anova(DIC_in_0, DIC_in_1)
  step(DIC_in_1)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    35 -1846.2 3762.4                          
## (1 | Month)           0   34 -1856.0 3780.0 19.6316  1   9.39e-06 ***
## (1 | SiteID)          0   34 -1848.4 3764.8  4.3996  1    0.03595 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                        Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Sub_region:Season          1  53301  5922.3     9 302.13  1.2744   0.25011
## Year:Sub_region                 2  13312  4437.5     3 311.20  0.9475   0.41789
## Year:Season                     0  43738 14579.4     3 149.31  3.1137   0.02811
## Sub_region:Season               0 194282 21586.9     9 314.18  4.6104 9.751e-06
##                           
## Year:Sub_region:Season    
## Year:Sub_region           
## Year:Season            *  
## Sub_region:Season      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Sub_region + Season + (1 | Month) + (1 | SiteID) + Year:Season + Sub_region:Season
  anova(DIC_in_1)
  ranova(DIC_in_1)
  step(DIC_in_1)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    35 -1846.2 3762.4                          
## (1 | Month)           0   34 -1856.0 3780.0 19.6316  1   9.39e-06 ***
## (1 | SiteID)          0   34 -1848.4 3764.8  4.3996  1    0.03595 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                        Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Sub_region:Season          1  53301  5922.3     9 302.13  1.2744   0.25011
## Year:Sub_region                 2  13312  4437.5     3 311.20  0.9475   0.41789
## Year:Season                     0  43738 14579.4     3 149.31  3.1137   0.02811
## Sub_region:Season               0 194282 21586.9     9 314.18  4.6104 9.751e-06
##                           
## Year:Sub_region:Season    
## Year:Sub_region           
## Year:Season            *  
## Sub_region:Season      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Sub_region + Season + (1 | Month) + (1 | SiteID) + Year:Season + Sub_region:Season
  DIC_in<-lmer(DIC_umol_kg ~ Year + Sub_region +
               (1 | Month) + (1 | SiteID),
                            data=Trends.inshore)
  anova(DIC_in)
  summary(DIC_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3971.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.1985 -0.6311 -0.0178  0.5971  4.1226 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 7095.6   84.24   
##  SiteID   (Intercept)  251.2   15.85   
##  Residual             5255.8   72.50   
## Number of obs: 347, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)  1505.8479  4868.1758  334.7412   0.309   0.7573   
## Year            0.2721     2.4124  334.7290   0.113   0.9103   
## Sub_regionUK  -16.5526    18.6644    7.1543  -0.887   0.4040   
## Sub_regionMK  -45.7023    18.5361    6.9628  -2.466   0.0433 * 
## Sub_regionLK  -70.2130    18.5236    6.9438  -3.790   0.0069 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.027  0.025              
## Sub_reginMK -0.014  0.011  0.591       
## Sub_reginLK -0.026  0.024  0.590  0.596
  plot(DIC_in)

  qqnorm(resid(DIC_in))

  acf(resid(DIC_in), main="acf(resid(DIC Inshore))")

  DIC_in.emmc<-emmeans(DIC_in, ~Sub_region)
    DIC_in.emmc<-multcomp::cld(DIC_in.emmc)
    #DIC_in.emmc<-as.data.frame(DIC_in.emmc[complete.cases(DIC_in.emmc),])
    DIC_in.emmc<-DIC_in.emmc[order(DIC_in.emmc$Sub_region),]
    DIC_in.emmc
  #write.csv(Temp_in.emmc, "FLK_results/Model_9_LTpH_POST.csv")
    round(DIC_in.emmc$emmean, digits = 2)
## [1] 2054.81 2038.26 2009.11 1984.60
    #anova(DIC_in)
    #ranova(DIC_in)
# Create a new data frame for independent variables  
  In_Newdata<-expand.grid(Sub_region=unique(Trends.inshore$Sub_region),
                          Year=seq((min(Trends.inshore$Year)-0),
                                   (max(Trends.inshore$Year)+1)))

  In_DIC_Pred <- predict(DIC_in, newdata=In_Newdata, 
                         re.form=NA, level=0, asList = FALSE)
  
  In_DIC_Pred <-cbind(In_Newdata, In_DIC_Pred)
  In_DIC_Pred$Date<-as.Date(as.character(In_DIC_Pred$Year), format = "%Y")
  
  
# Plot raw data point and fitted model 
  
  In_DIC_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(0,6),
                       name=(expression(~DIC[Ar])),
                       #limits = c(2.3, 5.2),
                       #breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=DIC_umol_kg, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=21)+
      geom_line(data=In_DIC_Pred, aes(y = In_DIC_Pred,
                                      x=Date, colour = Sub_region), linetype=2, size=1) 
  In_DIC_Modeled

Mid channel

hist(Trends.midchanel$DIC_umol_kg)

shapiro.test(Trends.midchanel$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$DIC_umol_kg
## W = 0.93309, p-value = 8.64e-11
DIC_mc_0<-lmer(DIC_umol_kg~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)

# DIC_mc_1<-lmer(DIC_umol_kg~Year * Sub_region * Season +
#                                     #(1|Zone)+             
#                                     (1|SiteID), data=Trends.midchanel)

#summary(DIC_mc_0)    
#summary(DIC_mc_1)  

anova(DIC_mc_0)
#anova(DIC_mc_1)
#anova(DIC_mc_0, DIC_mc_1)
ranova(DIC_mc_0)
step(DIC_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1662.8 3347.5                          
## (1 | SiteID)          1   10 -1663.5 3346.9   1.402  1     0.2363    
## (1 | Month)           0    9 -1728.8 3475.7 130.735  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  8960.2  2986.7     3 299.85  1.4641 0.224389   
## Year                     2  2124.8  2124.8     1 313.93  1.0364 0.309433   
## Sub_region               0 29902.5  9967.5     3 304.07  4.8510 0.002598 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Sub_region + (1 | Month)
DIC_mc<-lmer(DIC_umol_kg ~ Year + Sub_region + (1 | Month),
               data = Trends.midchanel)
  summary(DIC_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3343.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.3732 -0.4413  0.0604  0.5350  3.9154 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1700     41.23   
##  Residual             2050     45.28   
## Number of obs: 319, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  5223.535   3120.132  313.931   1.674 0.095099 .  
## Year           -1.574      1.546  313.932  -1.018 0.309433    
## Sub_regionUK   -8.601      8.196  302.877  -1.049 0.294825    
## Sub_regionMK  -21.738      7.268  302.850  -2.991 0.003011 ** 
## Sub_regionLK  -24.593      7.256  302.976  -3.389 0.000793 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.020  0.018              
## Sub_reginMK -0.004  0.003  0.530       
## Sub_reginLK -0.026  0.024  0.533  0.602
  anova(DIC_mc) 
  plot(DIC_mc)

  qqnorm(resid(DIC_mc))

  acf(resid(DIC_mc), main="acf(resid(DIC mid Channel))")  

  Temp_md.emmc<-emmeans(DIC_mc, ~Sub_region+Year)
    Temp_md.emmc<-multcomp::cld(Temp_md.emmc)
    #Temp_in.emmc<-as.data.frame(Temp_in.emmc[complete.cases(Temp_in.emmc),])
    Temp_md.emmc<-Temp_md.emmc[order(Temp_md.emmc$Sub_region),]
    Temp_md.emmc
  #write.csv(Temp_md.emmc, "FLK_results/Model_10_LTpH_POST.csv")
# Create a new data frame for independent variables  
  Mc_Newdata<-expand.grid(Zone=unique(Trends.midchanel$Zone),
                                Sub_region=unique(Trends.midchanel$Sub_region),
                          Year=seq((min(Trends.midchanel$Year)-0), (max(Trends.midchanel$Year)+1)))
  Mc_DIC_Pred <- predict(DIC_mc, newdata=Mc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Mc_DIC_Pred <-cbind(Mc_Newdata, Mc_DIC_Pred)
  Mc_DIC_Pred$Date<-as.Date(as.character(Mc_DIC_Pred$Year), format = "%Y")
  
  
# Model summary for labels
  slope<-round(
      summary(DIC_mc)$coefficients["Year", "Estimate"], digits = 3)
  ys <- max(Trends.midchanel$DIC_umol_kg, na.rm =T)+ 0.3

# Plot raw data point and fitted model 
  plot_label <- sprintf("\"\" ~ DIC[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
  Mc_DIC_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(DIC[Ar]))),
                       name=(expression(~DIC[Ar])),
                       limits = c(2.3, 5.2),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_jitter(data=Trends.midchanel, 
                               aes(y=DIC_umol_kg, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_DIC_Pred, aes(y = Mc_DIC_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      # geom_text(data = slope, aes(x = xs, y = ys,
      #                       label = (paste("~DIC[Ar]", "=", 
      #                                     slope, "Year ^-1"))), size=10)
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~DIC[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Mc_DIC_Modeled

Offshore

hist(Trends.offshore$DIC_umol_kg)

shapiro.test(Trends.offshore$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$DIC_umol_kg
## W = 0.92737, p-value = 8.011e-13
DIC_of_0<-lmer(DIC_umol_kg~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
#summary(DIC_of_0)    
anova(DIC_of_0)
ranova(DIC_of_0)
step(DIC_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1695.8 3413.7                         
## (1 | SiteID)          1   10 -1695.8 3411.7   0.00  1          1    
## (1 | Month)           0    9 -1757.9 3533.8 124.11  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  878.8  292.95     3 370.59  0.8509 0.466791   
## Year                     2  406.7  406.66     1 384.15  1.1825 0.277525   
## Sub_region               0 4526.5 1508.84     3 374.98  4.3971 0.004676 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Sub_region + (1 | Month)
DIC_of<-lmer(DIC_umol_kg ~ Year + Sub_region + (1 | Month), 
               data =Trends.offshore)
  summary(DIC_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3400.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.8843 -0.4329  0.1397  0.6130  2.4102 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 243.8    15.61   
##  Residual             343.9    18.54   
## Number of obs: 390, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)   792.3190  1154.5069  384.1392   0.686  0.49295   
## Year            0.6221     0.5721  384.1451   1.087  0.27753   
## Sub_regionUK   -2.9722     2.9870  373.5600  -0.995  0.32037   
## Sub_regionMK   -9.1133     2.9547  373.5576  -3.084  0.00219 **
## Sub_regionLK   -1.3305     2.8028  373.7602  -0.475  0.63528   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.007  0.006              
## Sub_reginMK -0.007  0.005  0.590       
## Sub_reginLK -0.020  0.019  0.624  0.632
  anova(DIC_of) 
  plot(DIC_of)

  qqnorm(resid(DIC_of))

  acf(resid(DIC_of), main="acf(resid(DIC offshore))")  

  Temp_of.emmc<-emmeans(DIC_of, ~Sub_region+Year)
    Temp_of.emmc<-multcomp::cld(Temp_of.emmc)
    #Temp_in.emmc<-as.data.frame(Temp_in.emmc[complete.cases(Temp_in.emmc),])
    Temp_of.emmc<-Temp_of.emmc[order(Temp_of.emmc$Sub_region),]
    Temp_of.emmc
#write.csv(Temp_of.emmc, "FLK_results/Model_11_LTpH_POST.csv")
# Create a new data frame for independent variables  
  Of_Newdata<-expand.grid(one=unique(Trends.offshore$Zone),
                                Sub_region=unique(Trends.offshore$Sub_region),
                          Year=seq((min(Trends.offshore$Year)-0), (max(Trends.offshore$Year)+1)))
  Of_DIC_Pred <- predict(DIC_of, newdata=Of_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Of_DIC_Pred <-cbind(Of_Newdata, Of_DIC_Pred)
  Of_DIC_Pred$Date<-as.Date(as.character(Of_DIC_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(DIC_of)$coefficients["Year", "Estimate"], digits = 3)
  ys <- max(Trends.offshore$DIC_umol_kg, na.rm =T)
  plot_label <- sprintf("\"\" ~ DIC[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Of_DIC_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(DIC[Ar]))),
                      name=(expression(~DIC[Ar])),
                       limits = c(3, 4.5),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=DIC_umol_kg, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_DIC_Pred, aes(y = Of_DIC_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~DIC[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Of_DIC_Modeled

Oceanic

hist(Trends.ocean$DIC_umol_kg)

shapiro.test(Trends.ocean$DIC_umol_kg)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$DIC_umol_kg
## W = 0.92806, p-value = 8.447e-07
DIC_oc_0<-lmer(DIC_umol_kg ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)

DIC_oc_1<-lmer(DIC_umol_kg ~ Year * Sub_region * Season++ (1|SiteID),
               data=Trends.ocean)
  #summary(DIC_oc_0)
  #summary(DIC_oc_1)    
  #anova(DIC_oc_1) 
  anova(DIC_oc_0)
  ranova(DIC_oc_0)
  step(DIC_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC   LRT Df Pr(>Chisq)    
## <none>                     9 -602.93 1223.8                        
## (1 | SiteID)          1    8 -602.93 1221.8  0.00  1          1    
## (1 | Month)           0    7 -620.68 1255.4 35.51  1  2.537e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  603.06  301.53     2 129.48  1.5503 0.216094   
## Sub_region               2  283.86  141.93     2 131.53  0.7231 0.487149   
## Year                     0 2034.28 2034.28     1 145.68 10.4027 0.001554 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + (1 | Month)
DIC_oc<-lmer(DIC_umol_kg ~ Year + (1 | Month), data = Trends.ocean)
  summary(DIC_oc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1222.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.9710 -0.4501  0.0728  0.5284  5.6177 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 181.8    13.48   
##  Residual             195.6    13.98   
## Number of obs: 148, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)   
## (Intercept) -2368.5433  1369.1200   145.6809  -1.730  0.08575 . 
## Year            2.1884     0.6785   145.6797   3.225  0.00155 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(DIC_oc)
  plot(DIC_oc)

  qqnorm(resid(DIC_oc))

  acf(resid(DIC_oc), main="acf(resid(DIC open))")

  Temp_oc.emmc<-emmeans(DIC_oc, ~Year)
    #Temp_oc.emmc<-multcomp::cld(Temp_oc.emmc)
    #Temp_oc.emmc<-as.data.frame(Temp_in.emmc[complete.cases(Temp_in.emmc),])
    #Temp_oc.emmc<-Temp_oc.emmc[order(Temp_oc.emmc$Sub_region),]
    #Temp_oc.emmc
# Create a new data frame for independent variables  
  Oc_Newdata<-expand.grid(one=unique(Trends.ocean$Zone),
                                Sub_region=unique(Trends.ocean$Sub_region),
                          Year=seq((min(Trends.ocean$Year)-0), (max(Trends.ocean$Year)+1)))
  Oc_DIC_Pred <- predict(DIC_oc, newdata=Oc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Oc_DIC_Pred <-cbind(Oc_Newdata, Oc_DIC_Pred)
  Oc_DIC_Pred$Date<-as.Date(as.character(Oc_DIC_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(DIC_oc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$DIC_umol_kg, na.rm =T)
  ys <- max(Trends.offshore$DIC_umol_kg, na.rm =T)
  plot_label <- sprintf("\"\" ~ DIC[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  
  Oc_DIC_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(DIC[Ar]))),
                      name=(expression(~DIC[Ar])),
                       limits = c(3, 4.5),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=DIC_umol_kg, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_DIC_Pred, aes(y = Oc_DIC_Pred,
                                      x=Date), linetype=1, size=1, colour = "black") +
    
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~DIC[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Oc_DIC_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.DIC_in_0 <- data.frame (anova(DIC_in_0))
    av.DIC_mc_0 <- data.frame (anova(DIC_mc_0) )
    av.DIC_of_0 <- data.frame (anova(DIC_of_0))
    av.DIC_oc_0 <- data.frame (anova(DIC_oc_0))
    
    # Putting all into one dataframe/table
    anova_DIC_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.DIC_in_0, av.DIC_mc_0,
                                            av.DIC_of_0, av.DIC_oc_0))) 
    colnames(anova_DIC_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_DIC_0) <- NULL
    
    # create HTML table using kableExtra
    anova_DIC_0 %>% kable("html", digits=2, 
        caption="Initial DIC models fixed factors: Year*Region") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "DIC inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "DIC mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "DIC offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "DIC ocean", 10, 12)  
Initial DIC models fixed factors: Year*Region
Sum Sq Mean Sq N Df D Df F value Pr(>F)
DIC inshore
Year 1.33 1.33 1 331.55 0.00 0.99
Sub_region 25822.77 8607.59 3 321.52 1.65 0.18
Year:Sub_region 25795.61 8598.54 3 321.52 1.65 0.18
DIC mid-channel
Year 2653.31 2653.31 1 306.00 1.32 0.25
Sub_region 9040.88 3013.63 3 294.59 1.50 0.21
Year:Sub_region 9040.52 3013.51 3 294.59 1.50 0.21
DIC offshore
Year 435.49 435.49 1 381.47 1.26 0.26
Sub_region 882.69 294.23 3 370.58 0.85 0.46
Year:Sub_region 878.84 292.95 3 370.58 0.85 0.47
DIC ocean
Year 1647.23 1647.23 1 141.16 8.47 0.00
Sub_region 602.62 301.31 2 129.49 1.55 0.22
Year:Sub_region 603.06 301.53 2 129.49 1.55 0.22
# R-ANOVAs    
    rav.DIC_in_0 <- data.frame (ranova(DIC_in_0))
    rav.DIC_mc_0 <- data.frame (ranova(DIC_mc_0) )
    rav.DIC_of_0 <- data.frame (ranova(DIC_of_0))
    rav.DIC_oc_0 <- data.frame (ranova(DIC_oc_0))
    
    # Putting all into one dataframe/table
    ranova_DIC_0 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.DIC_in_0, rav.DIC_mc_0,
                            rav.DIC_of_0, rav.DIC_oc_0))) 
    colnames(ranova_DIC_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_DIC_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_DIC_0 %>% kable("html", digits=2,
         caption="Initial DIC models random factors: Month+Station") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "DIC inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "DIC mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "DIC offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "DIC ocean", 10, 12)  
Initial DIC models random factors: Month+Station
npar logLik AIC LRT DF Pr(>Chi Sq)
DIC inshore
<none> 11 -1975.88 3973.76
(1 | Month) 10 -2094.12 4208.24 236.47 1 0.00
(1 | SiteID) 10 -1977.99 3975.98 4.22 1 0.04
DIC mid-channel
<none> 11 -1662.77 3347.54
(1 | Month) 10 -1728.78 3477.56 132.03 1 0.00
(1 | SiteID) 10 -1663.47 3346.94 1.40 1 0.24
DIC offshore
<none> 11 -1695.84 3413.68
(1 | Month) 10 -1757.89 3535.78 124.10 1 0.00
(1 | SiteID) 10 -1695.84 3411.68 0.00 1 1.00
DIC ocean
<none> 9 -602.93 1223.85
(1 | Month) 8 -620.68 1257.36 35.51 1 0.00
(1 | SiteID) 8 -602.93 1221.85 0.00 1 1.00
DIC_models_0<-list("Inshore" = DIC_in_0, 
                   "Mid channel" = DIC_mc_0, 
                   "Offshore" = DIC_of_0, 
                   "Ocean" = DIC_oc_0)
modelsummary(DIC_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Initial DIC model outputs (all factors)',
             coef_map=factor_order)
Initial DIC model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year −1.489 −1.711 0.411 2.017
(4.456) (2.801) (1.149) (1.333)
Intercept 5059.086 5499.903 1218.372 −2025.942
(8991.623) (5652.616) (2318.160) (2689.262)
Upper Keys 2656.414 1959.568 −317.924
(11390.728) (7765.744) (2873.140)
Middle Keys −16751.972 −7160.010 −2728.834 −2291.926
(11039.360) (6870.578) (2846.080) (3052.621)
Lower Keys 2257.089 5776.461 1062.283 1975.620
(11122.331) (6937.582) (2711.348) (3097.148)
Num.Obs. 347 319 390 148
R2 Marg. 0.058 0.035 0.043 0.122
R2 Cond. 0.609 0.487
AIC 3973.8 3347.5 3413.7 1223.9
BIC 4016.1 3389.0 3457.3 1250.8
ICC 0.6 0.5
RMSE 69.85 43.28 18.11 13.17
+ p
#modelsummary(DIC_models, estimate = "p.value")

Models with non-significant factors removed

DIC_models<-list("Inshore" = DIC_in, 
                   "Mid channel" = DIC_mc, 
                   "Offshore" = DIC_of, 
                   "Ocean" = DIC_oc)
modelsummary(DIC_models, stars = TRUE, 
            #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Final DIC model outputs (dropped factors)',
             coef_map=factor_order)
Final DIC model outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year 0.272 −1.574 0.622 2.188**
(2.412) (1.546) (0.572) (0.679)
Intercept 1505.848 5223.535+ 792.319 −2368.543+
(4868.176) (3120.132) (1154.507) (1369.120)
Upper Keys −16.553 −8.601 −2.972
(18.664) (8.196) (2.987)
Middle Keys −45.702* −21.738** −9.113**
(18.536) (7.268) (2.955)
Lower Keys −70.213*** −24.593*** −1.330
(18.524) (7.256) (2.803)
Num.Obs. 347 319 390 148
R2 Marg. 0.053 0.028 0.022 0.054
R2 Cond. 0.605 0.468 0.428 0.510
AIC 3987.6 3357.6 3414.6 1230.9
BIC 4018.3 3384.0 3442.4 1242.9
ICC 0.6 0.5 0.4 0.5
RMSE 70.39 44.17 18.17 13.41
+ p
modelsummary(DIC_models, output = "FLK_results/Figures/Fig_2/Trend_DIC.docx")
#modelsummary(DIC_models, estimate = "p.value")
Trends_DIC<-ggarrange(In_DIC_Modeled+ theme(
                                          #axis.text.x=element_blank(),
                                          legend.position = "none"),
                  Mc_DIC_Modeled+ theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Of_DIC_Modeled + theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Oc_DIC_Modeled + theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                           
          labels = c("C"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_DIC

Omega-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$Aragonite_Sat_W
## W = 0.96676, p-value = 5.771e-16

## Model with all data
Omega_all_o<-lmer(Aragonite_Sat_W~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
  step(Omega_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    33 -302.60 671.20                          
## (1 | SiteID)          1   32 -303.37 670.74   1.536  1     0.2153    
## (1 | Month)           0   31 -453.42 968.83 300.097  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Zone:Sub_region          1 0.1701 0.02126     8 1161.0  0.2546  0.979753
## Year:Sub_region               2 0.1190 0.03967     3 1169.2  0.4775  0.698004
## Year:Zone                     0 1.0532 0.35107     3 1172.0  4.2313  0.005506
## Zone:Sub_region               0 6.5766 0.82208     8 1172.0  9.9081 2.057e-13
##                         
## Year:Zone:Sub_region    
## Year:Sub_region         
## Year:Zone            ** 
## Zone:Sub_region      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone + Zone:Sub_region
Omega_all_1<-lmer(Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) +
                      Year:Zone + Zone:Sub_region, data=Trends.data)

Omega_all_3<-lmer(Aragonite_Sat_W ~ Year + Zone + (1 | Month) + (1|Sub_region)+
                       Year:Zone, data=Trends.data)
    

anova(Omega_all_1, Omega_all_3)
    summary(Omega_all_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: 
## Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone +  
##     Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: 544.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.6636 -0.5794  0.0809  0.5676  5.1487 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.03006  0.1734  
##  Residual             0.08297  0.2880  
## Number of obs: 1202, groups:  Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                  -3.176e+01  1.636e+01  1.183e+03  -1.942  0.05239
## Year                          1.755e-02  8.105e-03  1.183e+03   2.165  0.03057
## ZoneMid channel               2.090e+01  2.164e+01  1.172e+03   0.966  0.33414
## ZoneOffshore                  5.479e+01  2.060e+01  1.172e+03   2.659  0.00793
## ZoneOceanic                   8.328e+01  2.707e+01  1.172e+03   3.077  0.00214
## Sub_regionUK                  2.163e-01  4.677e-02  1.172e+03   4.625 4.16e-06
## Sub_regionMK                  9.860e-02  4.598e-02  1.172e+03   2.144  0.03220
## Sub_regionLK                 -3.035e-01  4.582e-02  1.172e+03  -6.624 5.33e-11
## Year:ZoneMid channel         -1.032e-02  1.072e-02  1.172e+03  -0.962  0.33603
## Year:ZoneOffshore            -2.709e-02  1.021e-02  1.172e+03  -2.654  0.00807
## Year:ZoneOceanic             -4.106e-02  1.341e-02  1.172e+03  -3.061  0.00226
## ZoneMid channel:Sub_regionUK -6.944e-02  7.000e-02  1.172e+03  -0.992  0.32145
## ZoneOffshore:Sub_regionUK    -1.756e-01  6.587e-02  1.172e+03  -2.666  0.00778
## ZoneOceanic:Sub_regionUK     -4.433e-01  7.992e-02  1.172e+03  -5.546 3.60e-08
## ZoneMid channel:Sub_regionMK -3.939e-02  6.515e-02  1.172e+03  -0.605  0.54554
## ZoneOffshore:Sub_regionMK    -7.577e-02  6.494e-02  1.172e+03  -1.167  0.24350
## ZoneOceanic:Sub_regionMK     -3.815e-01  6.672e-02  1.172e+03  -5.718 1.37e-08
## ZoneMid channel:Sub_regionLK  2.028e-01  6.488e-02  1.172e+03   3.126  0.00181
## ZoneOffshore:Sub_regionLK     2.626e-01  6.313e-02  1.172e+03   4.160 3.42e-05
##                                 
## (Intercept)                  .  
## Year                         *  
## ZoneMid channel                 
## ZoneOffshore                 ** 
## ZoneOceanic                  ** 
## Sub_regionUK                 ***
## Sub_regionMK                 *  
## Sub_regionLK                 ***
## Year:ZoneMid channel            
## Year:ZoneOffshore            ** 
## Year:ZoneOceanic             ** 
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK    ** 
## ZoneOceanic:Sub_regionUK     ***
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK       
## ZoneOceanic:Sub_regionMK     ***
## ZoneMid channel:Sub_regionLK ** 
## ZoneOffshore:Sub_regionLK    ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(Omega_all_1)
    ranova(Omega_all_1)
# Obtain slopes
    #ranef(Omega_all_1)
    #fixef(Omega_all_1)
    #coef(Omega_all_1)$Month
    #coef(Omega_all_1)$Zone

  m.lst <- lstrends(Omega_all_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend      SE   df lower.CL  upper.CL
##  Inshore        0.01755 0.00812 1183  0.00162  0.033479
##  Mid channel    0.00723 0.00837 1183 -0.00919  0.023650
##  Offshore      -0.00954 0.00768 1183 -0.02462  0.005531
##  Oceanic       -0.02351 0.01160 1180 -0.04627 -0.000745
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate     SE   df t.ratio p.value
##  Inshore - Mid channel    0.0103 0.0107 1172   0.962  0.7708
##  Inshore - Offshore       0.0271 0.0102 1172   2.654  0.0402
##  Inshore - Oceanic        0.0411 0.0134 1172   3.061  0.0121
##  Mid channel - Offshore   0.0168 0.0104 1172   1.611  0.3726
##  Mid channel - Oceanic    0.0307 0.0136 1172   2.266  0.1067
##  Offshore - Oceanic       0.0140 0.0132 1172   1.061  0.7136
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore

# Inshore Omega
  hist(Trends.inshore$Aragonite_Sat_W)

  shapiro.test(Trends.inshore$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$Aragonite_Sat_W
## W = 0.99052, p-value = 0.02452
  Omega_in_0<-lmer(Aragonite_Sat_W~Year * Sub_region + (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  Omega_in_1<-lmer(Aragonite_Sat_W~Year * Sub_region * Season +
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  #summary(Omega_in_0)
  #summary(Omega_in_1)    
  #anova(Omega_in_0, Omega_in_1)
  #step(Omega_in_1)
  
  anova(Omega_in_0)
  ranova(Omega_in_0)
  step(Omega_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -158.84 339.69                          
## (1 | Month)           0   10 -270.61 561.22 223.534  1    < 2e-16 ***
## (1 | SiteID)          0   10 -160.73 341.46   3.778  1    0.05193 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1 0.0355 0.01184     3 321.51  0.1021 0.958800   
## Year                     2 0.0130 0.01299     1 334.99  0.1129 0.737082   
## Sub_region               0 5.1444 1.71480     3   6.96 14.9425 0.002036 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Sub_region + (1 | Month) + (1 | SiteID)
  Omega_in<-lmer(Aragonite_Sat_W ~ Sub_region + (1 | Month),
                 data=Trends.inshore)
  anova(Omega_in)
  summary(Omega_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Sub_region + (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 297.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.5158 -0.5670  0.0272  0.5863  3.9500 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.1355   0.3681  
##  Residual             0.1184   0.3441  
## Number of obs: 347, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)    3.65604    0.11450  13.98288  31.930 1.82e-14 ***
## Sub_regionUK   0.20119    0.05589 332.16472   3.600 0.000367 ***
## Sub_regionMK   0.09851    0.05498 332.15825   1.792 0.074077 .  
## Sub_regionLK  -0.29697    0.05485 332.21792  -5.414 1.18e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.277              
## Sub_reginMK -0.283  0.576       
## Sub_reginLK -0.284  0.575  0.589
  plot(Omega_in)

  qqnorm(resid(Omega_in))

  acf(resid(Omega_in), main="acf(resid(Omega Inshore))")

  Arg_in.emmc<-emmeans(Omega_in, ~Sub_region)
    Arg_in.emmc<-multcomp::cld(Arg_in.emmc)
    #Arg_in.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    Arg_in.emmc<-Arg_in.emmc[order(Arg_in.emmc$Sub_region),]
    Arg_in.emmc
  #write.csv(Arg_in.emmc, "FLK_results/Model_9_LTpH_POST.csv")
    round(Arg_in.emmc$emmean, digits = 2)
## [1] 3.66 3.86 3.75 3.36
  #anova(Omega_in)
  #ranova(Omega_in)
# Create a new data frame for independent variables  
  In_Newdata<-expand.grid(Zone=unique(Trends.inshore$Zone),
                          Sub_region=unique(Trends.inshore$Sub_region),
                          Year=seq((min(Trends.inshore$Year)-0), (max(Trends.inshore$Year)+1)))
  In_Omega_Pred <- predict(Omega_in, newdata=In_Newdata, re.form=NA, level=0, asList = FALSE)
  
  In_Omega_Pred <-cbind(In_Newdata, In_Omega_Pred)
  In_Omega_Pred$Date<-as.Date(as.character(In_Omega_Pred$Year), format = "%Y")
  
  
# Plot raw data point and fitted model 
  
  In_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(0,6),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                       name=(expression(~Omega[Ar])),
                       limits = c(2.3, 5.2),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=21)+
      geom_line(data=In_Omega_Pred, aes(y = In_Omega_Pred,
                                      x=Date, colour = Sub_region), linetype=2, size=1) 
  In_Omega_Modeled

Mid channel

hist(Trends.midchanel$Aragonite_Sat_W)

shapiro.test(Trends.midchanel$Aragonite_Sat_W)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$Aragonite_Sat_W
## W = 0.97677, p-value = 4.94e-05
Omega_mc_0<-lmer(Aragonite_Sat_W~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)

# Omega_mc_1<-lmer(Aragonite_Sat_W~Year * Sub_region * Season +
#                                     #(1|Zone)+             
#                                     (1|SiteID), data=Trends.midchanel)

#summary(Omega_mc_0)    
#summary(Omega_mc_1)  

anova(Omega_mc_0)
#anova(Omega_mc_1)
#anova(Omega_mc_0, Omega_mc_1)
ranova(Omega_mc_0)
step(Omega_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik     AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -17.523  57.046                          
## (1 | SiteID)          1   10 -18.446  56.891   1.845  1     0.1744    
## (1 | Month)           0    9 -82.815 183.630 128.739  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1 0.05093 0.01698     3 300.21  0.3253    0.8071    
## Year                     2 0.02537 0.02537     1 313.50  0.4895    0.4847    
## Sub_region               0 2.54574 0.84858     3 304.19 16.3875 6.746e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Sub_region + (1 | Month)
Omega_mc<-lmer(Aragonite_Sat_W ~ Year + Sub_region + (1 | Month),
               data = Trends.midchanel)
  summary(Omega_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 18.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.4323 -0.5794  0.0884  0.6009  3.5273 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.03750  0.1936  
##  Residual             0.05184  0.2277  
## Number of obs: 319, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)   -7.215226  15.649192 313.494300  -0.461 0.645075    
## Year           0.005426   0.007755 313.497742   0.700 0.484664    
## Sub_regionUK   0.149803   0.041212 303.192891   3.635 0.000326 ***
## Sub_regionMK   0.058704   0.036548 303.162849   1.606 0.109271    
## Sub_regionLK  -0.099670   0.036486 303.301923  -2.732 0.006669 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.020  0.018              
## Sub_reginMK -0.004  0.003  0.530       
## Sub_reginLK -0.025  0.024  0.533  0.602
  anova(Omega_mc) 
  plot(Omega_mc)

  qqnorm(resid(Omega_mc))

  acf(resid(Omega_mc), main="acf(resid(Omega mid Channel))")  

  Arg_md.emmc<-emmeans(Omega_mc, ~Sub_region+Year)
    Arg_md.emmc<-multcomp::cld(Arg_md.emmc)
    #Arg_in.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    Arg_md.emmc<-Arg_md.emmc[order(Arg_md.emmc$Sub_region),]
    Arg_md.emmc
  #write.csv(Arg_md.emmc, "FLK_results/Model_10_LTpH_POST.csv")
# Create a new data frame for independent variables  
  Mc_Newdata<-expand.grid(Zone=unique(Trends.midchanel$Zone),
                                Sub_region=unique(Trends.midchanel$Sub_region),
                          Year=seq((min(Trends.midchanel$Year)-0), (max(Trends.midchanel$Year)+1)))
  Mc_Omega_Pred <- predict(Omega_mc, newdata=Mc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Mc_Omega_Pred <-cbind(Mc_Newdata, Mc_Omega_Pred)
  Mc_Omega_Pred$Date<-as.Date(as.character(Mc_Omega_Pred$Year), format = "%Y")
  
  
# Model summary for labels
  slope<-round(
      summary(Omega_mc)$coefficients["Year", "Estimate"], digits = 3)
  ys <- max(Trends.midchanel$Aragonite_Sat_W, na.rm =T)+ 0.3

# Plot raw data point and fitted model 
  plot_label <- sprintf("\"\" ~ Omega[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
  Mc_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                       name=(expression(~Omega[Ar])),
                       limits = c(2.3, 5.2),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_jitter(data=Trends.midchanel, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_Omega_Pred, aes(y = Mc_Omega_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      # geom_text(data = slope, aes(x = xs, y = ys,
      #                       label = (paste("~Omega[Ar]", "=", 
      #                                     slope, "Year ^-1"))), size=10)
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Mc_Omega_Modeled

Offshore

hist(Trends.offshore$Aragonite_Sat_W)

shapiro.test(Trends.offshore$Aragonite_Sat_W)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$Aragonite_Sat_W
## W = 0.99379, p-value = 0.1136
Omega_of_0<-lmer(Aragonite_Sat_W~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
#summary(Omega_of_0)    
anova(Omega_of_0)
ranova(Omega_of_0)
step(Omega_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC     LRT Df Pr(>Chisq)    
## <none>                    11 208.49 -394.97                          
## (1 | SiteID)          1   10 207.77 -395.53   1.438  1     0.2305    
## (1 | Month)           0    9 112.36 -206.72 190.817  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq  Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1 0.06605 0.022018     3 368.71  1.3883    0.2460    
## Year                     2 0.02010 0.020105     1 382.74  1.2636    0.2617    
## Sub_region               0 0.46970 0.156565     3 372.88  9.8508 2.883e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Sub_region + (1 | Month)
Omega_of<-lmer(Aragonite_Sat_W ~ Year + Sub_region + (1 | Month), 
               data =Trends.offshore)
  summary(Omega_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: -434.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.9928 -0.5880  0.0290  0.6318  3.7875 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.01749  0.1322  
##  Residual             0.01591  0.1261  
## Number of obs: 388, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)   
## (Intercept)   12.654489   7.902638 382.739787   1.601  0.11014   
## Year          -0.004402   0.003916 382.735971  -1.124  0.26167   
## Sub_regionUK   0.030178   0.020318 371.700710   1.485  0.13831   
## Sub_regionMK   0.023864   0.020098 371.699196   1.187  0.23584   
## Sub_regionLK  -0.051178   0.019121 371.848012  -2.677  0.00777 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.008  0.006              
## Sub_reginMK -0.007  0.006  0.590       
## Sub_reginLK -0.021  0.019  0.622  0.630
  anova(Omega_of) 
  plot(Omega_of)

  qqnorm(resid(Omega_of))

  acf(resid(Omega_of), main="acf(resid(Omega offshore))")  

  Arg_of.emmc<-emmeans(Omega_of, ~Sub_region+Year)
    Arg_of.emmc<-multcomp::cld(Arg_of.emmc)
    #Arg_in.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    Arg_of.emmc<-Arg_of.emmc[order(Arg_of.emmc$Sub_region),]
    Arg_of.emmc
#write.csv(Arg_of.emmc, "FLK_results/Model_11_LTpH_POST.csv")
# Create a new data frame for independent variables  
  Of_Newdata<-expand.grid(one=unique(Trends.offshore$Zone),
                                Sub_region=unique(Trends.offshore$Sub_region),
                          Year=seq((min(Trends.offshore$Year)-0), (max(Trends.offshore$Year)+1)))
  Of_Omega_Pred <- predict(Omega_of, newdata=Of_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Of_Omega_Pred <-cbind(Of_Newdata, Of_Omega_Pred)
  Of_Omega_Pred$Date<-as.Date(as.character(Of_Omega_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(Omega_of)$coefficients["Year", "Estimate"], digits = 3)
  ys <- max(Trends.offshore$Aragonite_Sat_W, na.rm =T)
  plot_label <- sprintf("\"\" ~ Omega[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Of_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                      name=(expression(~Omega[Ar])),
                       limits = c(3, 4.5),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_Omega_Pred, aes(y = Of_Omega_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Of_Omega_Modeled

Oceanic

hist(Trends.ocean$Aragonite_Sat_W)

shapiro.test(Trends.ocean$Aragonite_Sat_W)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$Aragonite_Sat_W
## W = 0.90529, p-value = 3.144e-08
Omega_oc_0<-lmer(Aragonite_Sat_W ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)

Omega_oc_1<-lmer(Aragonite_Sat_W ~ Year * Sub_region * Season++ (1|SiteID),
               data=Trends.ocean)
  #summary(Omega_oc_0)
  #summary(Omega_oc_1)    
  #anova(Omega_oc_1) 
  anova(Omega_oc_0)
  ranova(Omega_oc_0)
  step(Omega_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik      AIC    LRT Df Pr(>Chisq)    
## <none>                     9 63.501 -109.001                         
## (1 | SiteID)          1    8 63.501 -111.001   0.00  1          1    
## (1 | Month)           0    7 12.375  -10.751 102.25  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated   Sum Sq  Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1 0.039379 0.019689     2 130.49  1.3101 0.2733
## Year                     2 0.016473 0.016473     1 138.27  1.0905 0.2982
## Sub_region               3 0.056208 0.028104     2 133.73  1.8700 0.1581
## 
## Model found:
## Aragonite_Sat_W ~ (1 | Month)
Omega_oc<-lmer(Aragonite_Sat_W ~ Year + (1 | Month), data = Trends.ocean)
  summary(Omega_oc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: -146.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -6.4685 -0.5327  0.0287  0.5929  2.3286 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.04342  0.2084  
##  Residual             0.01530  0.1237  
## Number of obs: 148, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)  17.075542  12.373891 140.415184   1.380    0.170
## Year         -0.006584   0.006132 140.409085  -1.074    0.285
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(Omega_oc)
  plot(Omega_oc)

  qqnorm(resid(Omega_oc))

  acf(resid(Omega_oc), main="acf(resid(Omega open))")

  Arg_oc.emmc<-emmeans(Omega_oc, ~Year)
    #Arg_oc.emmc<-multcomp::cld(Arg_oc.emmc)
    #Arg_oc.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    #Arg_oc.emmc<-Arg_oc.emmc[order(Arg_oc.emmc$Sub_region),]
    #Arg_oc.emmc
# Create a new data frame for independent variables  
  Oc_Newdata<-expand.grid(one=unique(Trends.ocean$Zone),
                                Sub_region=unique(Trends.ocean$Sub_region),
                          Year=seq((min(Trends.ocean$Year)-0), (max(Trends.ocean$Year)+1)))
  Oc_Omega_Pred <- predict(Omega_oc, newdata=Oc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Oc_Omega_Pred <-cbind(Oc_Newdata, Oc_Omega_Pred)
  Oc_Omega_Pred$Date<-as.Date(as.character(Oc_Omega_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(Omega_oc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$Aragonite_Sat_W, na.rm =T)
  ys <- max(Trends.offshore$Aragonite_Sat_W, na.rm =T)
  plot_label <- sprintf("\"\" ~ Omega[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  
  Oc_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                      name=(expression(~Omega[Ar])),
                       limits = c(3, 4.5),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_Omega_Pred, aes(y = Oc_Omega_Pred,
                                      x=Date), linetype=1, size=1, colour = "black") +
    
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Oc_Omega_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.Omega_in_0 <- data.frame (anova(Omega_in_0))
    av.Omega_mc_0 <- data.frame (anova(Omega_mc_0) )
    av.Omega_of_0 <- data.frame (anova(Omega_of_0))
    av.Omega_oc_0 <- data.frame (anova(Omega_oc_0))
    
    # Putting all into one dataframe/table
    anova_Omega_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.Omega_in_0, av.Omega_mc_0,
                                            av.Omega_of_0, av.Omega_oc_0))) 
    colnames(anova_Omega_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_Omega_0) <- NULL
    
    # create HTML table using kableExtra
    anova_Omega_0 %>% kable("html", digits=2, 
        caption="Initial omega models fixed factors: Year*Region") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
Initial omega models fixed factors: Year*Region
Sum Sq Mean Sq N Df D Df F value Pr(>F)
Omega inshore
Year 0.01 0.01 1 332.03 0.08 0.78
Sub_region 0.04 0.01 3 321.51 0.10 0.96
Year:Sub_region 0.04 0.01 3 321.51 0.10 0.96
Omega mid-channel
Year 0.01 0.01 1 305.60 0.28 0.60
Sub_region 0.05 0.02 3 294.65 0.34 0.79
Year:Sub_region 0.05 0.02 3 294.65 0.34 0.80
Omega offshore
Year 0.03 0.03 1 371.83 1.77 0.18
Sub_region 0.07 0.02 3 360.94 1.41 0.24
Year:Sub_region 0.07 0.02 3 360.94 1.40 0.24
Omega ocean
Year 0.01 0.01 1 135.81 0.65 0.42
Sub_region 0.04 0.02 2 130.49 1.31 0.27
Year:Sub_region 0.04 0.02 2 130.49 1.31 0.27
# R-ANOVAs    
    rav.Omega_in_0 <- data.frame (ranova(Omega_in_0))
    rav.Omega_mc_0 <- data.frame (ranova(Omega_mc_0) )
    rav.Omega_of_0 <- data.frame (ranova(Omega_of_0))
    rav.Omega_oc_0 <- data.frame (ranova(Omega_oc_0))
    
    # Putting all into one dataframe/table
    ranova_Omega_0 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.Omega_in_0, rav.Omega_mc_0,
                            rav.Omega_of_0, rav.Omega_oc_0))) 
    colnames(ranova_Omega_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_Omega_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_Omega_0 %>% kable("html", digits=2,
         caption="Initial omega models random factors: Month+Station") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
Initial omega models random factors: Month+Station
npar logLik AIC LRT DF Pr(>Chi Sq)
Omega inshore
<none> 11 -158.84 339.69
(1 | Month) 10 -270.61 561.22 223.53 1 0.00
(1 | SiteID) 10 -160.73 341.46 3.78 1 0.05
Omega mid-channel
<none> 11 -17.52 57.05
(1 | Month) 10 -82.68 185.37 130.32 1 0.00
(1 | SiteID) 10 -18.45 56.89 1.84 1 0.17
Omega offshore
<none> 11 208.48 -394.97
(1 | Month) 10 112.36 -204.72 192.25 1 0.00
(1 | SiteID) 10 207.77 -395.53 1.44 1 0.23
Omega ocean
<none> 9 63.50 -109.00
(1 | Month) 8 12.38 -8.75 102.25 1 0.00
(1 | SiteID) 8 63.50 -111.00 0.00 1 1.00
Omega_models_0<-list("Inshore" = Omega_in_0, 
                   "Mid channel" = Omega_mc_0, 
                   "Offshore" = Omega_of_0, 
                   "Ocean" = Omega_oc_0)
modelsummary(Omega_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Initial Omega model outputs (all factors)',
             coef_map=factor_order)
Initial Omega model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year −0.006 −0.001 −0.008 −0.002
(0.021) (0.014) (0.008) (0.012)
Intercept 15.023 6.371 20.923 8.543
(42.358) (28.519) (15.637) (23.794)
Upper Keys −20.765 2.644 −12.566
(53.687) (39.216) (19.350)
Middle Keys −27.618 −18.546 8.870 25.277
(52.031) (34.693) (19.165) (26.849)
Lower Keys −22.317 −27.783 −22.561 −8.359
(52.422) (35.031) (18.267) (27.232)
Num.Obs. 347 319 388 148
R2 Marg. 0.127 0.084 0.042 0.053
R2 Cond. 0.606 0.480 0.554
AIC 339.7 57.0 −395.0 −109.0
BIC 382.0 98.5 −351.4 −82.0
ICC 0.5 0.4 0.5
RMSE 0.33 0.22 0.12 0.12
+ p
#modelsummary(Omega_models, estimate = "p.value")

Models with non-significant factors removed

Omega_models<-list("Inshore" = Omega_in, 
                   "Mid channel" = Omega_mc, 
                   "Offshore" = Omega_of, 
                   "Ocean" = Omega_oc)
modelsummary(Omega_models, stars = TRUE, 
            #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Final Omega model outputs (dropped factors)',
             coef_map=factor_order)
Final Omega model outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year 0.005 −0.004 −0.007
(0.008) (0.004) (0.006)
Intercept 3.656*** −7.215 12.654 17.076
(0.115) (15.649) (7.903) (12.374)
Upper Keys 0.201*** 0.150*** 0.030
(0.056) (0.041) (0.020)
Middle Keys 0.099+ 0.059 0.024
(0.055) (0.037) (0.020)
Lower Keys −0.297*** −0.100** −0.051**
(0.055) (0.036) (0.019)
Num.Obs. 347 319 388 148
R2 Marg. 0.129 0.084 0.038 0.003
R2 Cond. 0.594 0.468 0.542 0.740
AIC 309.6 32.4 −420.9 −138.1
BIC 332.7 58.8 −393.2 −126.1
ICC 0.5 0.4 0.5 0.7
RMSE 0.34 0.22 0.12 0.12
+ p
modelsummary(Omega_models, output = "FLK_results/Figures/Fig_2/Trend_Omega.docx")
#modelsummary(Omega_models, estimate = "p.value")
Trends_Omega<-ggarrange(In_Omega_Modeled+ theme(
                                          #axis.text.x=element_blank(),
                                          legend.position = "none"),
                  Mc_Omega_Modeled+ theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Of_Omega_Modeled + theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Oc_Omega_Modeled + theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                           
          labels = c("C"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_Omega

pCO2-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$pCO2_uatm
## W = 0.92391, p-value < 2.2e-16

## Model with all data
pCO2_all_o<-lmer(pCO2_uatm~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
    step(Omega_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    33 -302.60 671.20                          
## (1 | SiteID)          1   32 -303.37 670.74   1.536  1     0.2153    
## (1 | Month)           0   31 -453.42 968.83 300.097  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Zone:Sub_region          1 0.1701 0.02126     8 1161.0  0.2546  0.979753
## Year:Sub_region               2 0.1190 0.03967     3 1169.2  0.4775  0.698004
## Year:Zone                     0 1.0532 0.35107     3 1172.0  4.2313  0.005506
## Zone:Sub_region               0 6.5766 0.82208     8 1172.0  9.9081 2.057e-13
##                         
## Year:Zone:Sub_region    
## Year:Sub_region         
## Year:Zone            ** 
## Zone:Sub_region      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone + Zone:Sub_region
pCO2_all_o_1<-lmer(pCO2_uatm ~ Year + Zone + Sub_region + (1 | Month) +
                      Year:Zone + Zone:Sub_region, data=Trends.data)

pCO2_all_o_3<-lmer(pCO2_uatm ~ Year + Zone + (1 | Month) + (1|Sub_region)+
                       Year:Zone, data=Trends.data)
    

anova(pCO2_all_o, pCO2_all_o_1, pCO2_all_o_3)
    summary(pCO2_all_o_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone +  
##     Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: 12892.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.4226 -0.4951 -0.1069  0.4715  9.8228 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1919     43.81   
##  Residual             2815     53.05   
## Number of obs: 1202, groups:  Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                    7923.307   3019.203   1181.115   2.624 0.008795
## Year                             -3.711      1.496   1181.096  -2.480 0.013271
## ZoneMid channel               -6600.698   3984.938   1172.077  -1.656 0.097906
## ZoneOffshore                 -11827.038   3794.255   1172.164  -3.117 0.001871
## ZoneOceanic                  -17773.780   4984.880   1172.117  -3.566 0.000378
## Sub_regionUK                    -26.654      8.614   1172.009  -3.094 0.002021
## Sub_regionMK                    -30.269      8.469   1172.010  -3.574 0.000366
## Sub_regionLK                     16.564      8.440   1172.062   1.963 0.049922
## Year:ZoneMid channel              3.262      1.975   1172.077   1.652 0.098827
## Year:ZoneOffshore                 5.853      1.880   1172.164   3.113 0.001900
## Year:ZoneOceanic                  8.790      2.470   1172.117   3.558 0.000388
## ZoneMid channel:Sub_regionUK     10.213     12.894   1172.019   0.792 0.428449
## ZoneOffshore:Sub_regionUK        19.779     12.133   1172.006   1.630 0.103317
## ZoneOceanic:Sub_regionUK         33.407     14.720   1172.033   2.270 0.023415
## ZoneMid channel:Sub_regionMK     19.871     12.000   1171.980   1.656 0.097997
## ZoneOffshore:Sub_regionMK        21.957     11.960   1171.980   1.836 0.066635
## ZoneOceanic:Sub_regionMK         46.300     12.288   1171.984   3.768 0.000173
## ZoneMid channel:Sub_regionLK     -9.327     11.950   1171.977  -0.781 0.435242
## ZoneOffshore:Sub_regionLK       -16.100     11.628   1171.981  -1.385 0.166457
##                                 
## (Intercept)                  ** 
## Year                         *  
## ZoneMid channel              .  
## ZoneOffshore                 ** 
## ZoneOceanic                  ***
## Sub_regionUK                 ** 
## Sub_regionMK                 ***
## Sub_regionLK                 *  
## Year:ZoneMid channel         .  
## Year:ZoneOffshore            ** 
## Year:ZoneOceanic             ***
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK       
## ZoneOceanic:Sub_regionUK     *  
## ZoneMid channel:Sub_regionMK .  
## ZoneOffshore:Sub_regionMK    .  
## ZoneOceanic:Sub_regionMK     ***
## ZoneMid channel:Sub_regionLK    
## ZoneOffshore:Sub_regionLK       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(pCO2_all_o_1)
    ranova(pCO2_all_o_1)
# Obtain slopes
    
    ranef(pCO2_all_o_1)
## $Month
##     (Intercept)
## Apr  -58.142133
## May  -55.254247
## Jun    3.487297
## Jul   42.308538
## Aug   38.627165
## Sep   59.772212
## Oct   50.461554
## Nov   20.226263
## Dec    2.741919
## Jan  -10.876983
## Feb  -45.762902
## Mar  -47.588682
## 
## with conditional variances for "Month"
    fixef(pCO2_all_o_1)
##                  (Intercept)                         Year 
##                  7923.306666                    -3.710778 
##              ZoneMid channel                 ZoneOffshore 
##                 -6600.698165                -11827.038267 
##                  ZoneOceanic                 Sub_regionUK 
##                -17773.780213                   -26.654277 
##                 Sub_regionMK                 Sub_regionLK 
##                   -30.268537                    16.564376 
##         Year:ZoneMid channel            Year:ZoneOffshore 
##                     3.262160                     5.852538 
##             Year:ZoneOceanic ZoneMid channel:Sub_regionUK 
##                     8.790155                    10.213277 
##    ZoneOffshore:Sub_regionUK     ZoneOceanic:Sub_regionUK 
##                    19.779107                    33.406978 
## ZoneMid channel:Sub_regionMK    ZoneOffshore:Sub_regionMK 
##                    19.871245                    21.956598 
##     ZoneOceanic:Sub_regionMK ZoneMid channel:Sub_regionLK 
##                    46.299702                    -9.327342 
##    ZoneOffshore:Sub_regionLK 
##                   -16.099874
    coef(pCO2_all_o_1)$Month
    coef(pCO2_all_o_1)$Zone
## NULL
  m.lst <- lstrends(pCO2_all_o_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend   SE   df lower.CL upper.CL
##  Inshore         -3.711 1.50 1181   -6.649   -0.772
##  Mid channel     -0.449 1.54 1181   -3.477    2.580
##  Offshore         2.142 1.42 1181   -0.639    4.923
##  Oceanic          5.079 2.14 1177    0.884    9.275
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate   SE   df t.ratio p.value
##  Inshore - Mid channel     -3.26 1.97 1172  -1.652  0.3500
##  Inshore - Offshore        -5.85 1.88 1172  -3.113  0.0102
##  Inshore - Oceanic         -8.79 2.47 1172  -3.558  0.0022
##  Mid channel - Offshore    -2.59 1.92 1172  -1.351  0.5306
##  Mid channel - Oceanic     -5.53 2.50 1172  -2.213  0.1204
##  Offshore - Oceanic        -2.94 2.42 1172  -1.212  0.6196
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore

# Inshore pCO2
  hist(Trends.inshore$pCO2_uatm)

  shapiro.test(Trends.inshore$pCO2_uatm)# Normality NOT? rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$pCO2_uatm
## W = 0.97119, p-value = 2.168e-06
  pCO2_in_0<-lmer(pCO2_uatm~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.inshore)
  #summary(pCO2_in_0)    
  anova(pCO2_in_0)
  ranova(pCO2_in_0)
  step(pCO2_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1960.9 3943.7                          
## (1 | Month)           0   10 -2082.9 4185.9 244.167  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1964.4 3948.8   7.104  1    0.00769 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1  14407  4802.2     3 321.29  1.0116 0.3877
## Year                     2   2648  2648.5     1 334.11  0.5577 0.4557
## Sub_region               3  37312 12437.2     3   7.00  2.6243 0.1323
## 
## Model found:
## pCO2_uatm ~ (1 | Month) + (1 | SiteID)
pCO2_in<-lmer(pCO2_uatm ~ (1|Month)+(1|SiteID), data=Trends.inshore)
  summary(pCO2_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3972.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.5290 -0.6081 -0.0745  0.5398  7.1829 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 7029.7   83.84   
##  SiteID   (Intercept)  568.5   23.84   
##  Residual             4738.5   68.84   
## Number of obs: 347, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   425.68      25.55  12.80   16.66 4.71e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  anova(pCO2_in)
  plot(pCO2_in)

  qqnorm(resid(pCO2_in))

  acf(resid(pCO2_in), main="acf(resid(pCO2 Inshore))")  

  #pCO2_in.emmc<-emmeans(pCO2_in, ~Month)
      #pCO2_in.emmc<-multcomp::cld(pCO2_in.emmc)
      #pCO2_in.emmc<-pCO2_in.emmc[order(pCO2_in.emmc$Sub_region),]
      #pCO2_in.emmc
# Predict values  
  In_pCO2_Pred <- predict(pCO2_in, newdata=In_Newdata, re.form=NA, level=0, asList = FALSE)
  
  In_pCO2_Pred <-cbind(In_Newdata, In_pCO2_Pred)
  In_pCO2_Pred$Date<-as.Date(as.character(In_pCO2_Pred$Year), format = "%Y")
  
# # Model summary
#   slope<-round(
#       summary(pCO2_in)$coefficients["Year", "Estimate"], digits = 3)
#   xs <- as.Date(as.character("2018-11-20"))
#   ys <- max(Trends.midchanel$pCO2_uatm, na.rm =T)
# 
# # Plot raw data point and fitted model 
#   plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
#   plot_label2 <- expression("Year^-1")
  
  
# Plot raw data point and fitted model 
  
  In_pCO2_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                        limits = c(200,800),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=pCO2_uatm, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                  alpha=0.5, size=0.5, shape=21)+
      geom_line(data=In_pCO2_Pred, aes(y = In_pCO2_Pred,
                                      x=Date), linetype=2, size=1, colour = "black")

  In_pCO2_Modeled

Mid channel

hist(Trends.midchanel$pCO2_uatm)

shapiro.test(Trends.midchanel$pCO2_uatm)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$pCO2_uatm
## W = 0.99101, p-value = 0.04862
pCO2_mc_0<-lmer(pCO2_uatm~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)
  #summary(pCO2_mc_0)    
  anova(pCO2_mc_0)
  ranova(pCO2_mc_0)
  step(pCO2_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1602.9 3227.7                          
## (1 | SiteID)          1   10 -1603.6 3227.2   1.453  1      0.228    
## (1 | Month)           0    9 -1706.5 3431.0 205.873  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1  5080.2  1693.4     3 300.03  1.2392 0.2956304    
## Year                     2   409.9   409.9     1 313.01  0.2993 0.5847329    
## Sub_region               0 27356.2  9118.7     3 304.06  6.6755 0.0002232 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pCO2_uatm ~ Sub_region + (1 | Month)
pCO2_mc<-lmer(pCO2_uatm ~ Year + Sub_region + (1 | Month), 
              data = Trends.midchanel)
  summary(pCO2_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3222
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0752 -0.6290 -0.1366  0.6270  4.0314 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1815     42.60   
##  Residual             1370     37.01   
## Number of obs: 319, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)  
## (Intercept)  1822.0813  2568.2119  313.0123   0.709   0.4786  
## Year           -0.6962     1.2727  313.0065  -0.547   0.5847  
## Sub_regionUK  -16.9020     6.6997  303.0578  -2.523   0.0122 *
## Sub_regionMK   -9.9623     5.9415  303.0405  -1.677   0.0946 .
## Sub_regionLK    7.5901     5.9317  303.1191   1.280   0.2017  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.020  0.019              
## Sub_reginMK -0.004  0.003  0.530       
## Sub_reginLK -0.026  0.024  0.533  0.602
   anova(pCO2_mc)
   plot(pCO2_mc)

  qqnorm(resid(pCO2_mc))

  acf(resid(pCO2_mc), main="acf(resid(pCO2 Mid Channel))")  

  pCO2_mc.emmc<-emmeans(pCO2_mc, ~Sub_region+Year)
        pCO2_mc.emmc<-multcomp::cld(pCO2_mc.emmc)
        pCO2_mc.emmc<-pCO2_mc.emmc[order(
          pCO2_mc.emmc$Sub_region),]
  pCO2_mc.emmc
  #write.csv(pCO2_mc.emmc, "FLK_results/Model_2_LTpCO2_POST.csv")
# Predict values  
  Mc_pCO2_Pred <- predict(pCO2_mc, newdata=Mc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Mc_pCO2_Pred <-cbind(Mc_Newdata, Mc_pCO2_Pred)
  Mc_pCO2_Pred$Date<-as.Date(as.character(Mc_pCO2_Pred$Year), format = "%Y")
  
 # Model summary
  slope<-round(
      summary(pCO2_mc)$coefficients["Year", "Estimate"], digits = 3)
  #ys <- max(Trends.inshore$pCO2_uatm, na.rm =T)
  ys <- max(Trends.midchanel$pCO2_uatm, na.rm =T)+50

# Plot raw data point and fitted model 
  plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
  
# Plot raw data point and fitted model 
  
  Mc_pCO2_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                       limits = c(200,800),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.midchanel, 
                               aes(y=pCO2_uatm, x=Date, #fill = Sub_region), 
                                  colour = Sub_region),  
                               alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_pCO2_Pred, aes(y = Mc_pCO2_Pred,
                                      x=Date, colour = Sub_region),
                linetype=1, size=1) +
     annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Mc_pCO2_Modeled

Offshore

hist(Trends.offshore$pCO2_uatm)

shapiro.test(Trends.offshore$pCO2_uatm)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$pCO2_uatm
## W = 0.98049, p-value = 4.25e-05
pCO2_of_0<-lmer(pCO2_uatm~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(pCO2_of_0)    
  anova(pCO2_of_0)
  ranova(pCO2_of_0)
  step(pCO2_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1754.3 3530.6                         
## (1 | SiteID)          1   10 -1754.3 3528.6   0.00  1          1    
## (1 | Month)           0    9 -1888.3 3794.7 268.04  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          0   4488    1496     3 368.87  3.1239 0.02594 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pCO2_uatm ~ Year + Sub_region + (1 | Month) + Year:Sub_region
pCO2_of<-lmer(pCO2_uatm ~ Year + Sub_region + (1 | Month),
              data =Trends.offshore)
  summary(pCO2_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3525.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8917 -0.6612 -0.0745  0.5456  5.1171 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 792.6    28.15   
##  Residual             487.1    22.07   
## Number of obs: 388, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)  
## (Intercept)  -2868.7304  1388.0888   381.0773  -2.067   0.0394 *
## Year             1.6282     0.6879   381.0643   2.367   0.0184 *
## Sub_regionUK    -5.4089     3.5549   371.8480  -1.522   0.1290  
## Sub_regionMK    -8.5154     3.5165   371.8470  -2.422   0.0159 *
## Sub_regionLK     2.0882     3.3455   371.9472   0.624   0.5329  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.008  0.006              
## Sub_reginMK -0.007  0.006  0.590       
## Sub_reginLK -0.021  0.019  0.622  0.630
  anova(pCO2_of)
  plot(pCO2_of)

  qqnorm(resid(pCO2_of))

  acf(resid(Omega_in), main="acf(resid(pCO2 Offshore))")  

  pCO2_of.emmc<-emmeans(pCO2_of, ~Sub_region)
        pCO2_of.emmc<-multcomp::cld(pCO2_of.emmc)
        pCO2_of.emmc<-pCO2_of.emmc[order(pCO2_of.emmc$Sub_region),]
  pCO2_of.emmc
  #write.csv(pCO2_of.emmc, "FLK_results/Model_3_LTpCO2_POST.csv")
# Predict values  
  Of_pCO2_Pred <- predict(pCO2_of, newdata=Of_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Of_pCO2_Pred <-cbind(Of_Newdata, Of_pCO2_Pred)
  Of_pCO2_Pred$Date<-as.Date(as.character(Of_pCO2_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  slope<-round(
      summary(pCO2_of)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  ys <- max(Trends.offshore$pCO2_uatm, na.rm =T) -15
  plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Of_pCO2_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                       limits = c(300,605),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=pCO2_uatm, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_pCO2_Pred, aes(y = Of_pCO2_Pred,
                                      x=Date, colour = Sub_region),
                linetype=1, size=1) +
     annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Of_pCO2_Modeled

Oceanic

hist(Trends.ocean$pCO2_uatm)

shapiro.test(Trends.ocean$pCO2_uatm)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$pCO2_uatm
## W = 0.88517, p-value = 2.506e-09
pCO2_oc_0<-lmer(pCO2_uatm ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(pCO2_oc_0)    
  anova(pCO2_oc_0)
  ranova(pCO2_oc_0)
  step(pCO2_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -682.07 1382.1                         
## (1 | SiteID)          1    8 -682.07 1380.1  0.000  1     0.9999    
## (1 | Month)           0    7 -696.67 1407.3 29.202  1  6.522e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)  
## Year:Sub_region          1 2542.1 1271.05     2 132.19  2.0233 0.1363  
## Sub_region               2 1046.3  523.14     2 134.28  0.8205 0.4424  
## Year                     3 2388.0 2388.03     1 142.33  3.7529 0.0547 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pCO2_uatm ~ (1 | Month)
pCO2_oc<-lmer(pCO2_uatm ~ Year + (1 | Month), 
              data = Trends.ocean)
  summary(pCO2_oc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1387
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.0803 -0.5007 -0.0498  0.4464  7.2224 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 250.2    15.82   
##  Residual             636.3    25.23   
## Number of obs: 148, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)  
## (Intercept) -4213.683   2389.335   142.325  -1.764   0.0800 .
## Year            2.294      1.184   142.329   1.937   0.0547 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(pCO2_oc) 
  plot(pCO2_oc)

  qqnorm(resid(pCO2_oc))

  acf(resid(pCO2_oc), main="acf(resid(pCO2 open))")

  pCO2_oc.emmc<-emmeans(pCO2_oc, ~Year)
        pCO2_oc.emmc<-multcomp::cld(pCO2_oc.emmc)
        #pCO2_oc.emmc<-pCO2_oc.emmc[order(pCO2_oc.emmc$Sub_region),]
  pCO2_oc.emmc
# Predict values  
  Oc_pCO2_Pred <- predict(pCO2_oc, newdata=Oc_Newdata, 
                          re.form=NA, level=0, asList = FALSE)
  Oc_pCO2_Pred <-cbind(Oc_Newdata, Oc_pCO2_Pred)
  Oc_pCO2_Pred$Date<-as.Date(as.character(Oc_pCO2_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  slope<-round(
      summary(pCO2_oc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  ys <- max(Trends.offshore$pCO2_uatm, na.rm =T)-15
  plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Oc_pCO2_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                       limits = c(300,605),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=pCO2_uatm, x=Date, #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_pCO2_Pred, aes(y = Oc_pCO2_Pred, x=Date), 
                          colour = "black", linetype=1, size=1) +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
              label =paste0(as.character(plot_label, plot_label2, sep = " ")),
              size=4)
  Oc_pCO2_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    
    av.pCO2_in_0 <- data.frame (anova(pCO2_in_0))
    av.pCO2_mc_0 <- data.frame (anova(pCO2_mc_0) )
    av.pCO2_of_0 <- data.frame (anova(pCO2_of_0))
    av.pCO2_oc_0 <- data.frame (anova(pCO2_oc_0))
    
    # Putting all into one dataframe/table
    anova_pH <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                      rbind(av.pCO2_in_0, av.pCO2_mc_0,
                      av.pCO2_of_0, av.pCO2_oc_0))) 
    colnames(anova_pH) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_pH) <- NULL
    
    # create HTML table using kableExtra
    anova_pH %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "pCO2 inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "pCO2 mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "pCO2 offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "pCO2 ocean", 10, 12)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
pCO2 inshore
Year 2463.70 2463.70 1 331.01 0.52 0.47
Sub_region 14472.40 4824.13 3 321.29 1.02 0.39
Year:Sub_region 14406.68 4802.23 3 321.29 1.01 0.39
pCO2 mid-channel
Year 279.44 279.44 1 304.56 0.21 0.65
Sub_region 5172.46 1724.15 3 294.68 1.28 0.28
Year:Sub_region 5153.88 1717.96 3 294.68 1.28 0.28
pCO2 offshore
Year 3634.86 3634.86 1 377.77 7.59 0.01
Sub_region 4496.27 1498.76 3 368.89 3.13 0.03
Year:Sub_region 4488.04 1496.01 3 368.89 3.12 0.03
pCO2 ocean
Year 1298.46 1298.46 1 140.16 2.07 0.15
Sub_region 2540.18 1270.09 2 132.19 2.02 0.14
Year:Sub_region 2542.11 1271.05 2 132.19 2.02 0.14
# R-ANOVAs    
    rav.pCO2_in_0 <- data.frame (ranova(pCO2_in_0))
    rav.pCO2_mc_0 <- data.frame (ranova(pCO2_mc_0) )
    rav.pCO2_of_0 <- data.frame (ranova(pCO2_of_0))
    rav.pCO2_oc_0 <- data.frame (ranova(pCO2_oc_0))
    
    # Putting all into one dataframe/table
    ranova_pCO2 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.pCO2_in_0, rav.pCO2_mc_0,
                            rav.pCO2_of_0, rav.pCO2_oc_0))) 
    colnames(ranova_pCO2) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_pCO2) <- NULL
    
    # create HTML table using kableExtra
    ranova_pCO2 %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
npar logLik AIC LRT DF Pr(>Chi Sq)
Omega inshore
<none> 11 -1960.86 3943.72
(1 | Month) 10 -2082.94 4185.89 244.17 1 0.00
(1 | SiteID) 10 -1964.41 3948.82 7.10 1 0.01
Omega mid-channel
<none> 11 -1602.86 3227.71
(1 | Month) 10 -1706.52 3433.04 207.33 1 0.00
(1 | SiteID) 10 -1603.58 3227.17 1.45 1 0.23
Omega offshore
<none> 11 -1754.32 3530.63
(1 | Month) 10 -1888.34 3796.67 268.04 1 0.00
(1 | SiteID) 10 -1754.32 3528.63 0.00 1 1.00
Omega ocean
<none> 9 -682.07 1382.13
(1 | Month) 8 -696.67 1409.33 29.20 1 0.00
(1 | SiteID) 8 -682.07 1380.13 0.00 1 1.00
pCO2_models_0<-list("Inshore" = pCO2_in_0, 
                   "Mid channel" = pCO2_mc_0, 
                   "Offshore" = pCO2_of_0, 
                   "Ocean" = pCO2_oc_0)
modelsummary(pCO2_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pCO model outputs (all factors)',
             coef_map=factor_order)
pCO model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year 0.297 0.493 3.299* 0.261
(4.249) (2.297) (1.359) (2.372)
Intercept −163.198 −578.151 −6239.564* −117.276
(8573.324) (4634.475) (2741.383) (4786.602)
Upper Keys 4386.682 1146.061 3881.748
(10859.179) (6354.925) (3388.676)
Middle Keys −2246.265 −806.335 −181.767 −8472.658
(10523.741) (5622.170) (3356.720) (5480.976)
Lower Keys 13637.873 8339.327 7481.548* −728.455
(10602.918) (5677.101) (3199.251) (5563.983)
Num.Obs. 347 319 388 148
R2 Marg. 0.032 0.031 0.032 0.071
R2 Cond. 0.616 0.593 0.635
AIC 3943.7 3227.7 3530.6 1382.1
BIC 3986.1 3269.1 3574.2 1409.1
ICC 0.6 0.6 0.6
RMSE 66.52 35.40 21.35 23.77
+ p
#modelsummary(Omega_models, estimate = "p.value")

Factors removed models

pCO2_models<-list("Inshore" = pCO2_in, 
                   "Mid channel" = pCO2_mc, 
                   "Offshore" = pCO2_of, 
                   "Ocean" = pCO2_oc)
modelsummary(pCO2_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pCO2 models outputs (dropped factors)',
             coef_map=factor_order)
pCO2 models outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year −0.696 1.628* 2.294+
(1.273) (0.688) (1.184)
Intercept 425.681*** 1822.081 −2868.730* −4213.683+
(25.549) (2568.212) (1388.089) (2389.335)
Upper Keys −16.902* −5.409
(6.700) (3.555)
Middle Keys −9.962+ −8.515*
(5.942) (3.516)
Lower Keys 7.590 2.088
(5.932) (3.346)
Num.Obs. 347 319 388 148
R2 Marg. 0.000 0.027 0.024 0.026
R2 Cond. 0.616 0.581 0.628 0.301
AIC 3980.8 3236.0 3539.3 1395.0
BIC 3996.2 3262.3 3567.1 1407.0
ICC 0.6 0.6 0.6 0.3
RMSE 66.86 36.09 21.62 24.28
+ p
#modelsummary(pCO2_models, estimate = "p.value")
Trends_pCO2<-ggarrange(In_pCO2_Modeled+ theme(axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 legend.position = "none"),
                  Mc_pCO2_Modeled + theme(legend.position = "none",
                                 axis.title.y=element_blank(),
                                 axis.text.x=element_blank()),
                                
                  Of_pCO2_Modeled + theme(legend.position = "none",
                                           axis.title.y=element_blank(),
                                           axis.text.x=element_blank()),
                                
                  Oc_pCO2_Modeled + theme(legend.position = "none",
                                           axis.title.y=element_blank(),
                                           axis.text.x=element_blank()),
                  
          labels = c("A"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_pCO2

pH-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$pH_calculated
## W = 0.95916, p-value < 2.2e-16

## Model with all data
pH_all_o<-lmer(pH_calculated ~ Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
    step(pH_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    33 1912.5 -3759.0                         
## (1 | Month)           0   32 1592.7 -3121.3 639.67  1    < 2e-16 ***
## (1 | SiteID)          0   32 1910.5 -3757.1   3.89  1    0.04871 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated   Sum Sq   Mean Sq NumDF   DenDF F value
## Year:Zone:Sub_region          1 0.001540 0.0001925     8 1139.90  0.1031
## Year:Sub_region               2 0.012630 0.0042099     3 1147.15  2.2692
## Year:Zone                     0 0.037848 0.0126161     3 1149.97  6.7767
## Zone:Sub_region               0 0.044190 0.0055237     8   23.65  2.9671
##                         Pr(>F)    
## Year:Zone:Sub_region 0.9991245    
## Year:Sub_region      0.0788897 .  
## Year:Zone            0.0001572 ***
## Zone:Sub_region      0.0188489 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Year + Zone + Sub_region + (1 | Month) + (1 | SiteID) + Year:Zone + Zone:Sub_region
pH_all_o_1<-lmer(pH_calculated ~ Year + Zone + Sub_region + (1 | Month) +
                      Year:Zone + Zone:Sub_region, data=Trends.data)

pH_all_o_3<-lmer(pH_calculated ~ Year + Zone + (1 | Month) + (1|Sub_region)+
                       Year:Zone, data=Trends.data)
    

anova(pH_all_o, pH_all_o_1, pH_all_o_3)
    summary(pH_all_o_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone +  
##     Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: -3921.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -6.5800 -0.5213  0.0656  0.4949  4.6575 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.001768 0.04205 
##  Residual             0.001887 0.04344 
## Number of obs: 1202, groups:  Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                   1.367e+00  2.474e+00  1.179e+03   0.552 0.580764
## Year                          3.302e-03  1.226e-03  1.179e+03   2.693 0.007178
## ZoneMid channel               5.957e+00  3.263e+00  1.172e+03   1.826 0.068141
## ZoneOffshore                  1.094e+01  3.107e+00  1.172e+03   3.522 0.000445
## ZoneOceanic                   1.594e+01  4.082e+00  1.172e+03   3.906 9.92e-05
## Sub_regionUK                  2.424e-02  7.054e-03  1.172e+03   3.437 0.000609
## Sub_regionMK                  1.728e-02  6.934e-03  1.172e+03   2.492 0.012823
## Sub_regionLK                 -2.795e-02  6.911e-03  1.172e+03  -4.045 5.57e-05
## Year:ZoneMid channel         -2.948e-03  1.617e-03  1.172e+03  -1.823 0.068527
## Year:ZoneOffshore            -5.419e-03  1.540e-03  1.172e+03  -3.519 0.000449
## Year:ZoneOceanic             -7.883e-03  2.023e-03  1.172e+03  -3.897 0.000103
## ZoneMid channel:Sub_regionUK -8.027e-03  1.056e-02  1.172e+03  -0.760 0.447201
## ZoneOffshore:Sub_regionUK    -1.935e-02  9.934e-03  1.172e+03  -1.948 0.051645
## ZoneOceanic:Sub_regionUK     -4.318e-02  1.205e-02  1.172e+03  -3.582 0.000354
## ZoneMid channel:Sub_regionMK -1.081e-02  9.826e-03  1.172e+03  -1.100 0.271552
## ZoneOffshore:Sub_regionMK    -1.211e-02  9.793e-03  1.172e+03  -1.236 0.216535
## ZoneOceanic:Sub_regionMK     -4.395e-02  1.006e-02  1.172e+03  -4.368 1.37e-05
## ZoneMid channel:Sub_regionLK  1.680e-02  9.785e-03  1.172e+03   1.717 0.086267
## ZoneOffshore:Sub_regionLK     2.607e-02  9.522e-03  1.172e+03   2.738 0.006281
##                                 
## (Intercept)                     
## Year                         ** 
## ZoneMid channel              .  
## ZoneOffshore                 ***
## ZoneOceanic                  ***
## Sub_regionUK                 ***
## Sub_regionMK                 *  
## Sub_regionLK                 ***
## Year:ZoneMid channel         .  
## Year:ZoneOffshore            ***
## Year:ZoneOceanic             ***
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK    .  
## ZoneOceanic:Sub_regionUK     ***
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK       
## ZoneOceanic:Sub_regionMK     ***
## ZoneMid channel:Sub_regionLK .  
## ZoneOffshore:Sub_regionLK    ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(pH_all_o_1)
    ranova(pH_all_o_1)
    ranef(pH_all_o_1)
## $Month
##      (Intercept)
## Apr  0.052537644
## May  0.046227147
## Jun -0.013039323
## Jul -0.047433841
## Aug -0.040070419
## Sep -0.057214875
## Oct -0.040240854
## Nov -0.016435554
## Dec  0.001651854
## Jan  0.015533741
## Feb  0.052333930
## Mar  0.046150550
## 
## with conditional variances for "Month"
    fixef(pH_all_o_1)
##                  (Intercept)                         Year 
##                  1.366691432                  0.003301801 
##              ZoneMid channel                 ZoneOffshore 
##                  5.957402352                 10.941634460 
##                  ZoneOceanic                 Sub_regionUK 
##                 15.943021621                  0.024243735 
##                 Sub_regionMK                 Sub_regionLK 
##                  0.017283650                 -0.027954363 
##         Year:ZoneMid channel            Year:ZoneOffshore 
##                 -0.002948182                 -0.005418733 
##             Year:ZoneOceanic ZoneMid channel:Sub_regionUK 
##                 -0.007883005                 -0.008027417 
##    ZoneOffshore:Sub_regionUK     ZoneOceanic:Sub_regionUK 
##                 -0.019352940                 -0.043178165 
## ZoneMid channel:Sub_regionMK    ZoneOffshore:Sub_regionMK 
##                 -0.010808465                 -0.012108819 
##     ZoneOceanic:Sub_regionMK ZoneMid channel:Sub_regionLK 
##                 -0.043949576                  0.016799753 
##    ZoneOffshore:Sub_regionLK 
##                  0.026067218
    coef(pH_all_o_1)$Month
    coef(pH_all_o_1)$Zone
## NULL
  m.lst <- lstrends(pH_all_o_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend      SE   df  lower.CL  upper.CL
##  Inshore       0.003302 0.00123 1179  0.000895  0.005709
##  Mid channel   0.000354 0.00126 1179 -0.002127  0.002834
##  Offshore     -0.002117 0.00116 1180 -0.004395  0.000161
##  Oceanic      -0.004581 0.00175 1176 -0.008017 -0.001145
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate      SE   df t.ratio p.value
##  Inshore - Mid channel   0.00295 0.00162 1172   1.823  0.2628
##  Inshore - Offshore      0.00542 0.00154 1172   3.519  0.0025
##  Inshore - Oceanic       0.00788 0.00202 1172   3.897  0.0006
##  Mid channel - Offshore  0.00247 0.00157 1172   1.574  0.3942
##  Mid channel - Oceanic   0.00493 0.00205 1172   2.412  0.0753
##  Offshore - Oceanic      0.00246 0.00199 1172   1.241  0.6007
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates
  # Create a new data frame for independent variables  
  Newdata<-expand.grid(Zone=unique(Trends.data$Zone),
                          Sub_region=unique(Trends.data$Sub_region),
                          Year=seq((min(Trends.data$Year)-0), (max(Trends.data$Year)+1)))
  
  # Predict values  
  pH_Pred <- predict(pH_all_o_1, newdata=Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  pH_Pred <-cbind(Newdata, pH_Pred)
  pH_Pred$Date<-as.Date(as.character(pH_Pred$Year), format = "%Y")
  

pH_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                       limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.data, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5,shape=21)+
      geom_line(data=pH_Pred, aes(y = pH_Pred, x=Date,  colour = Sub_region),
                                linetype=2, size=1) #+
      #annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
      #        label =paste0(as.character(plot_label, plot_label2, sep = " ")),
      #        size=4)
  pH_Modeled

Inshore

# Inshore pH
hist(Trends.inshore$pH_calculated)

shapiro.test(Trends.inshore$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$pH_calculated
## W = 0.99359, p-value = 0.1483
pH_in_0<-lmer(pH_calculated~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID),
            data=Trends.inshore)
  #summary(pH_in_0)    
  anova(pH_in_0)
  ranova(pH_in_0)
  step(pH_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC     LRT Df Pr(>Chisq)    
## <none>                    11 464.47 -906.94                          
## (1 | Month)           0   10 316.60 -613.19 295.746  1    < 2e-16 ***
## (1 | SiteID)          0   10 461.43 -902.87   6.067  1    0.01377 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated   Sum Sq   Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1 0.006900 0.0022998     3 321.24  0.7999 0.49464  
## Year                     2 0.000653 0.0006535     1 332.54  0.2276 0.63361  
## Sub_region               0 0.046162 0.0153874     3   7.01  5.3752 0.03095 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Sub_region + (1 | Month) + (1 | SiteID)
pH_in<-lmer(pH_calculated ~ Sub_region + (1 | Month) + (1 | SiteID),
            data=Trends.inshore)
  summary(pH_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: -965.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.8544 -0.6181  0.0023  0.5730  3.7735 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Month    (Intercept) 0.0057552 0.07586 
##  SiteID   (Intercept) 0.0001789 0.01337 
##  Residual             0.0028627 0.05350 
## Number of obs: 347, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)   8.02899    0.02476 15.41449 324.269   <2e-16 ***
## Sub_regionUK  0.02212    0.01499  7.00533   1.475    0.184    
## Sub_regionMK  0.01751    0.01491  6.85157   1.175    0.279    
## Sub_regionLK -0.02659    0.01489  6.83100  -1.785    0.118    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.357              
## Sub_reginMK -0.359  0.592       
## Sub_reginLK -0.359  0.592  0.596
  anova(pH_in)
  plot(pH_in)

  qqnorm(resid(pH_in))

  acf(resid(pH_in), main="acf(resid(pH Inshore))")  

  pH_in.emmc<-emmeans(pH_in, ~Sub_region)
        pH_in.emmc<-multcomp::cld(pH_in.emmc)
        pH_in.emmc<-pH_in.emmc[order(pH_in.emmc$Sub_region),]
  pH_in.emmc
#write.csv(pH_in.emmc, "FLK_results/Model_5_LTpH_POST.csv")
# Predict values  
  In_pH_Pred <- predict(pH_in, newdata=In_Newdata, 
                        re.form=NA, level=0, asList = FALSE)
    In_pH_Pred <-cbind(In_Newdata, In_pH_Pred)
  In_pH_Pred$Date<-as.Date(as.character(In_pH_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  # slope<-round(
  #     summary(pH_in)$coefficients["Year", "Estimate"], digits = 3)
  # xs <- as.Date(as.character("2018-11-20"))
  # ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  # plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  # plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  In_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                       limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5,shape=21)+
      geom_line(data=In_pH_Pred, aes(y = In_pH_Pred, x=Date,  colour = Sub_region),
                                linetype=2, size=1) #+
      #annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
      #        label =paste0(as.character(plot_label, plot_label2, sep = " ")),
      #        size=4)
  In_pH_Modeled

Mid channel

hist(Trends.midchanel$pH_calculated)

shapiro.test(Trends.midchanel$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$pH_calculated
## W = 0.97575, p-value = 3.242e-05
pH_mc_0<-lmer(pH_calculated~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID),
            data=Trends.midchanel)
  #summary(pH_mc_0)    
  anova(pH_mc_0)
  ranova(pH_mc_0)
  step(pH_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik      AIC     LRT Df Pr(>Chisq)    
## <none>                    11 575.00 -1128.00                          
## (1 | SiteID)          1   10 574.49 -1128.99   1.017  1     0.3133    
## (1 | Month)           0    9 461.28  -904.56 226.423  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated    Sum Sq   Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Sub_region          1 0.0031140 0.0010380     3 299.99  0.9248    0.4291
## Year                     2 0.0002402 0.0002402     1 312.24  0.2142    0.6438
## Sub_region               0 0.0314885 0.0104962     3 304.03  9.3869 5.957e-06
##                    
## Year:Sub_region    
## Year               
## Sub_region      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Sub_region + (1 | Month)
pH_mc<-lmer(pH_calculated ~ Year + Sub_region + (1 | Month),
            data = Trends.midchanel)
  summary(pH_mc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: -1177.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.3996 -0.6123  0.0126  0.5291  4.1156 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.001746 0.04178 
##  Residual             0.001122 0.03349 
## Number of obs: 319, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)   
## (Intercept)   6.960e+00  2.328e+00  3.122e+02   2.990  0.00302 **
## Year          5.339e-04  1.154e-03  3.122e+02   0.463  0.64384   
## Sub_regionUK  1.668e-02  6.062e-03  3.030e+02   2.752  0.00628 **
## Sub_regionMK  6.264e-03  5.376e-03  3.030e+02   1.165  0.24491   
## Sub_regionLK -1.117e-02  5.367e-03  3.031e+02  -2.081  0.03823 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.020  0.019              
## Sub_reginMK -0.004  0.003  0.530       
## Sub_reginLK -0.026  0.025  0.533  0.602
  anova(pH_mc)
  plot(pH_mc)

  qqnorm(resid(pH_mc))

  acf(resid(pH_mc), main="acf(resid(pH Mid Channel))")  

  pH_mc.emmc<-emmeans(pH_mc, ~Sub_region)
        pH_mc.emmc<-multcomp::cld(pH_mc.emmc)
        pH_mc.emmc<-pH_mc.emmc[order(pH_mc.emmc$Sub_region),]
  pH_mc.emmc
  #write.csv(pH_mc.emmc, "FLK_results/Model_6_LTpH_POST.csv")
# Predict values  
  Mc_pH_Pred <- predict(pH_mc, newdata=Mc_Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  Mc_pH_Pred <-cbind(Mc_Newdata, Mc_pH_Pred)
  Mc_pH_Pred$Date<-as.Date(as.character(Mc_pH_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  slope<-round(
      summary(pH_mc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  ys <- max(Trends.midchanel$pH_calculated, na.rm =T)+0.03
  plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Mc_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                       breaks = seq(0, 10, 0.1),  
                       limits=c(7.80, 8.28),
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.midchanel, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_pH_Pred, aes(y = Mc_pH_Pred, x=Date,  colour = Sub_region),
                                linetype=1, size=1) +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
           label =paste0(as.character(plot_label, plot_label2, sep = " ")),
           size=4)
  Mc_pH_Modeled

Offshore

hist(Trends.offshore$pH_calculated)

shapiro.test(Trends.offshore$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$pH_calculated
## W = 0.99092, p-value = 0.01729
pH_of_0<-lmer(pH_calculated~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(pH_of_0)    
  anova(pH_of_0)
  ranova(pH_of_0)
  step(pH_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    11 920.71 -1819.4                         
## (1 | SiteID)          1   10 920.71 -1821.4   0.00  1          1    
## (1 | Month)           0    9 767.35 -1516.7 306.73  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated    Sum Sq   Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          0 0.0033325 0.0011108     3 368.84   3.037 0.02913 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Year + Sub_region + (1 | Month) + Year:Sub_region
pH_of<-lmer(pH_calculated ~ Year + Sub_region + (1 | Month), 
            data =Trends.offshore)
  summary(pH_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: -1867.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.5593 -0.5678  0.0880  0.6617  3.0799 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Month    (Intercept) 0.0007452 0.02730 
##  Residual             0.0003717 0.01928 
## Number of obs: 388, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)   1.043e+01  1.215e+00  3.800e+02   8.591 2.26e-16 ***
## Year         -1.188e-03  6.019e-04  3.799e+02  -1.973   0.0492 *  
## Sub_regionUK  3.608e-03  3.106e-03  3.719e+02   1.162   0.2461    
## Sub_regionMK  5.338e-03  3.072e-03  3.719e+02   1.738   0.0831 .  
## Sub_regionLK -3.117e-03  2.923e-03  3.719e+02  -1.066   0.2869    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.008  0.006              
## Sub_reginMK -0.007  0.006  0.590       
## Sub_reginLK -0.021  0.019  0.622  0.630
   anova(pH_of)
   plot(pH_of)

  qqnorm(resid(pH_of))

  acf(resid(pH_of), main="acf(resid(pH Offshore))")

  pH_of.emmc<-emmeans(pH_of, ~Sub_region)
        pH_of.emmc<-multcomp::cld(pH_of.emmc)
        pH_of.emmc<-pH_of.emmc[order(pH_of.emmc$Sub_region),]
  pH_of.emmc
 #write.csv(pH_of.emmc, "FLK_results/Model_7_LTpH_POST.csv")
# Predict values  
  Of_pH_Pred <- predict(pH_of, newdata=Of_Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  Of_pH_Pred <-cbind(Of_Newdata, Of_pH_Pred)
  Of_pH_Pred$Date<-as.Date(as.character(Of_pH_Pred$Year), format = "%Y")

# Model summary for slope labels 
  slope<-round(
      summary(pH_of)$coefficients["Year", "Estimate"], digits = 3)
  #ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  ys <- max(Trends.offshore$pH_calculated, na.rm =T)+0.08
  plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  plot_label2 <- expression("Year^-1")  
  
# Plot raw data point and fitted model 
  Of_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                      limits=c(7.88, 8.2),
                      # limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0, 0.01)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                               alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_pH_Pred, aes(y = Of_pH_Pred, x=Date,  colour = Sub_region),
                                linetype=1, size=1) +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
           label =paste0(as.character(plot_label, plot_label2, sep = " ")),
           size=4)
  Of_pH_Modeled

Oceanic

hist(Trends.ocean$pH_calculated)

shapiro.test(Trends.ocean$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$pH_calculated
## W = 0.93998, p-value = 6.014e-06
pH_oc_0<-lmer(pH_calculated ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(pH_oc_0)    
  anova(pH_oc_0)
  ranova(pH_oc_0)
  step(pH_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                     9 324.53 -631.05                         
## (1 | SiteID)          1    8 324.53 -633.05  0.000  1     0.9999    
## (1 | Month)           0    7 305.14 -596.27 38.776  1  4.753e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated     Sum Sq    Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1 0.00141777 0.00070889     2 132.05  1.6468 0.1966
## Sub_region               2 0.00073784 0.00036892     2 134.10  0.8493 0.4300
## Year                     3 0.00087168 0.00087168     1 144.81  2.0100 0.1584
## 
## Model found:
## pH_calculated ~ (1 | Month)
pH_oc<-lmer(pH_calculated ~ Year + (1 | Month),
               data=Trends.ocean)
  summary(pH_oc)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: -683.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -6.5077 -0.4574  0.0159  0.5652  2.1918 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Month    (Intercept) 0.0002218 0.01489 
##  Residual             0.0004337 0.02082 
## Number of obs: 148, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)  1.087e+01  1.996e+00  1.448e+02   5.445 2.17e-07 ***
## Year        -1.403e-03  9.892e-04  1.448e+02  -1.418    0.158    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(pH_oc) 
  plot(pH_oc)

  qqnorm(resid(pH_oc))

  acf(resid(pH_oc), main="acf(resid(pH ocean))")

  pH_oc.emmc<-emmeans(pH_oc, ~Year)
        pH_oc.emmc<-multcomp::cld(pH_oc.emmc)
        #pH_oc.emmc<-pH_oc.emmc[order(pH_oc.emmc$Sub_region),]
  pH_oc.emmc
# Predict values  
  Oc_pH_Pred <- predict(pH_oc, newdata=Oc_Newdata,
                        re.form=NA, level=0, asList = FALSE)
  Oc_pH_Pred <-cbind(Oc_Newdata, Oc_pH_Pred)
  Oc_pH_Pred$Date<-as.Date(as.character(Oc_pH_Pred$Year), format = "%Y")

# Model summary for slope labels 
  slope<-round(
      summary(pH_oc)$coefficients["Year", "Estimate"], digits = 3)
  #ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  ys <- max(Trends.offshore$pH_calculated, na.rm =T)+0.08
  plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  plot_label2 <- expression("Year^-1")  
  
# Plot raw data point and fitted model 
  Oc_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                      limits=c(7.88, 8.2),
                      # limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0, 0.01)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=pH_calculated, x=Date, #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_pH_Pred, aes(y = Oc_pH_Pred, x=Date),
                                linetype=1, size=1, colour = "black") +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
           label =paste0(as.character(plot_label, plot_label2, sep = " ")),
           size=4)
  Oc_pH_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.pH_in_0 <- data.frame (anova(pH_in_0))
    av.pH_mc_0 <- data.frame (anova(pH_mc_0) )
    av.pH_of_0 <- data.frame (anova(pH_of_0))
    av.pH_oc_0 <- data.frame (anova(pH_oc_0))
    
    # Putting all into one dataframe/table
    anova_pH <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                         rbind(av.pH_in_0, av.pH_mc_0,
                         av.pH_of_0, av.pH_oc_0))) 
    colnames(anova_pH) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_pH) <- NULL
  
  # create HTML table using kableExtra
  anova_pH %>% kable("html", digits=2) %>% 
  kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "pH inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "pH mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "pH offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "pH ocean", 10, 12)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
pH inshore
Year 0.00 0 1 329.42 0.14 0.71
Sub_region 0.01 0 3 321.24 0.80 0.49
Year:Sub_region 0.01 0 3 321.24 0.80 0.49
pH mid-channel
Year 0.00 0 1 303.84 0.12 0.73
Sub_region 0.00 0 3 294.68 0.95 0.42
Year:Sub_region 0.00 0 3 294.68 0.95 0.42
pH offshore
Year 0.00 0 1 376.66 5.67 0.02
Sub_region 0.00 0 3 368.90 3.04 0.03
Year:Sub_region 0.00 0 3 368.90 3.04 0.03
pH ocean
Year 0.00 0 1 141.59 0.90 0.34
Sub_region 0.00 0 2 132.05 1.65 0.20
Year:Sub_region 0.00 0 2 132.05 1.65 0.20
# R-ANOVAs    
    rav.pH_in_0 <- data.frame (ranova(pH_in_0))
    rav.pH_mc_0 <- data.frame (ranova(pH_mc_0) )
    rav.pH_of_0 <- data.frame (ranova(pH_of_0))
    rav.pH_oc_0 <- data.frame (ranova(pH_oc_0))
    
    # Putting all into one dataframe/table
    ranova_pH <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.pH_in_0, rav.pH_mc_0,
                            rav.pH_of_0, rav.pH_oc_0))) 
    colnames(ranova_pH) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_pH) <- NULL
    
    # create HTML table using kableExtra
    ranova_pH %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "pH inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "pH mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "pH offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "pH ocean", 10, 12)  
npar logLik AIC LRT DF Pr(>Chi Sq)
pH inshore
<none> 11 464.47 -906.94
(1 | Month) 10 316.60 -613.19 295.75 1 0.00
(1 | SiteID) 10 461.43 -902.87 6.07 1 0.01
pH mid-channel
<none> 11 575.00 -1128.00
(1 | Month) 10 461.28 -902.56 227.44 1 0.00
(1 | SiteID) 10 574.49 -1128.99 1.02 1 0.31
pH offshore
<none> 11 920.71 -1819.43
(1 | Month) 10 767.35 -1514.69 306.73 1 0.00
(1 | SiteID) 10 920.71 -1821.43 0.00 1 1.00
pH ocean
<none> 9 324.53 -631.05
(1 | Month) 8 305.14 -594.27 38.78 1 0.00
(1 | SiteID) 8 324.53 -633.05 0.00 1 1.00
pH_models_0<-list("Inshore" = pH_in_0, 
                   "Mid channel" = pH_mc_0, 
                   "Offshore" = pH_of_0, 
                   "Ocean" = pH_oc_0)
modelsummary(pH_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pH model outputs (all factors)',
             coef_map=factor_order)
pH model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year −0.002 −0.001 −0.003* 0.000
(0.003) (0.002) (0.001) (0.002)
Intercept 12.081+ 10.029* 13.706*** 7.416+
(6.677) (4.209) (2.397) (3.975)
Upper Keys −4.133 −2.200 −3.793
(8.451) (5.768) (2.962)
Middle Keys −5.187 −1.337 −0.425 6.694
(8.190) (5.104) (2.934) (4.539)
Lower Keys −12.284 −7.655 −6.779* 1.147
(8.252) (5.153) (2.796) (4.606)
Num.Obs. 347 319 388 148
R2 Marg. 0.046 0.037 0.024 0.052
R2 Cond. 0.686 0.629 0.678
AIC −906.9 −1128.0 −1819.4 −631.1
BIC −864.6 −1086.6 −1775.9 −604.1
ICC 0.7 0.6 0.7
RMSE 0.05 0.03 0.02 0.02
+ p
#modelsummary(pH_models, estimate = "p.value")

Factors removed models

pH_models<-list("Inshore" = pH_in, 
                   "Mid channel" = pH_mc, 
                   "Offshore" = pH_of, 
                   "Ocean" = pH_oc)
modelsummary(pH_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pH model outputs (factors dropped)',
             coef_map=factor_order)
pH model outputs (factors dropped)
Inshore Mid channel Offshore Ocean
Year 0.001 −0.001* −0.001
(0.001) (0.001) (0.001)
Intercept 8.029*** 6.960** 10.434*** 10.868***
(0.025) (2.328) (1.215) (1.996)
Upper Keys 0.022 0.017** 0.004
(0.015) (0.006) (0.003)
Middle Keys 0.018 0.006 0.005+
(0.015) (0.005) (0.003)
Lower Keys −0.027+ −0.011* −0.003
(0.015) (0.005) (0.003)
Num.Obs. 347 319 388 148
R2 Marg. 0.043 0.034 0.016 0.013
R2 Cond. 0.689 0.622 0.673 0.347
AIC −951.5 −1163.1 −1853.2 −675.7
BIC −924.6 −1136.8 −1825.5 −663.7
ICC 0.7 0.6 0.7 0.3
RMSE 0.05 0.03 0.02 0.02
+ p
#modelsummary(pH_models, estimate = "p.value")
Trends_pH<-ggarrange(In_pH_Modeled+ theme(axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 legend.position = "none"),
                  Mc_pH_Modeled + theme(legend.position = "none",
                                 axis.text.x=element_blank(),
                                  axis.title.y=element_blank()),
                                
                  Of_pH_Modeled + theme(legend.position = "none",
                                        axis.text.x=element_blank(),
                                        axis.title.y=element_blank()),
                                
                  Oc_pH_Modeled + theme(legend.position = "none",
                                        axis.text.x=element_blank(),
                                        axis.title.y=element_blank()),
                  
          labels = c("B"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_pH

TA-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$TA_umol_kg
## W = 0.8049, p-value < 2.2e-16

Inshore

# Inshore TA
hist(Trends.inshore$TA_umol_kg)

shapiro.test(Trends.inshore$TA_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$TA_umol_kg
## W = 0.97145, p-value = 2.182e-06
TA_in_0<-lmer(TA_umol_kg~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.inshore)
  #summary(TA_in_0)    
  anova(TA_in_0)
  ranova(TA_in_0)
  step(TA_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1990.5 4003.0                          
## (1 | SiteID)          1   10 -1991.5 4002.9   1.923  1     0.1656    
## (1 | Month)           0    9 -2069.8 4157.7 156.779  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)    
## Year:Sub_region          1  26521    8840     3 331.02  1.6535 0.1769    
## Year                     2     26      26     1 344.93  0.0049 0.9441    
## Sub_region               0 560636  186879     3 335.08 34.8434 <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Sub_region + (1 | Month)
TA_in<-lmer(TA_umol_kg ~ Sub_region + (1 | Month), 
            data=Trends.inshore)
  summary(TA_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ Sub_region + (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 4006.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.5370 -0.5310  0.0517  0.5682  4.7726 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 4637     68.10   
##  Residual             5363     73.24   
## Number of obs: 350, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  2375.078     21.652   14.670 109.693  < 2e-16 ***
## Sub_regionUK    3.191     11.896  334.979   0.268  0.78870    
## Sub_regionMK  -32.099     11.701  334.967  -2.743  0.00641 ** 
## Sub_regionLK  -94.998     11.622  335.135  -8.174 6.21e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.312              
## Sub_reginMK -0.318  0.576       
## Sub_reginLK -0.321  0.578  0.593
  plot(TA_in)

  qqnorm(resid(TA_in))

  acf(resid(TA_in), main="acf(resid(TA Inshore))") 

  TA_in.emmc<-emmeans(TA_in, ~Sub_region)
        TA_in.emmc<-multcomp::cld(TA_in.emmc)
        TA_in.emmc<-TA_in.emmc[order(TA_in.emmc$Sub_region),]
  TA_in.emmc

Mid channel

hist(Trends.midchanel$TA_umol_kg)

shapiro.test(Trends.midchanel$TA_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$TA_umol_kg
## W = 0.87228, p-value = 1.176e-15
TA_mc_0<-lmer(TA_umol_kg~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID),
            data=Trends.midchanel)
  #summary(TA_mc_0)    
  anova(TA_mc_0)
  ranova(TA_mc_0)
  step(TA_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1664.4 3350.8                         
## (1 | Month)           0   10 -1702.0 3424.0 75.168  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1665.8 3351.7  2.878  1    0.08979 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF   DenDF F value  Pr(>F)  
## Year:Sub_region          1  6526.0  2175.3     3 296.129  1.1327 0.33606  
## Year                     2   605.8   605.8     1 305.751  0.3149 0.57510  
## Sub_region               0 27707.5  9235.8     3   6.215  4.8026 0.04686 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Sub_region + (1 | Month) + (1 | SiteID)
TA_mc<-lmer(TA_umol_kg ~ (1 | Month) + (1|SiteID), 
            data = Trends.midchanel)
  summary(TA_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ (1 | Month) + (1 | SiteID)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3376.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.1017 -0.4452  0.1164  0.5311  3.4719 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  905.6   30.09   
##  SiteID   (Intercept)  251.2   15.85   
##  Residual             1923.6   43.86   
## Number of obs: 321, groups:  Month, 12; SiteID, 10
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  2362.52      10.36   15.75   228.1   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(TA_mc)

  qqnorm(resid(TA_mc))

  acf(resid(TA_mc), main="acf(resid(TA Mid Channel))") 

Offshore

hist(Trends.offshore$TA_umol_kg)

shapiro.test(Trends.offshore$TA_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$TA_umol_kg
## W = 0.88004, p-value < 2.2e-16
TA_of_0<-lmer(TA_umol_kg~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(TA_of_0)    
  anova(TA_of_0)
  ranova(TA_of_0)
  step(TA_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1681.9 3385.8                         
## (1 | SiteID)          1   10 -1681.9 3383.8  0.000  1          1    
## (1 | Month)           0    9 -1712.8 3443.7 61.928  1  3.562e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  193.64   64.55     3 371.60  0.2024 0.89468  
## Year                     2    3.81    3.81     1 366.89  0.0120 0.91276  
## Sub_region               0 2944.96  981.65     3 376.33  3.1051 0.02658 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Sub_region + (1 | Month)
TA_of<-lmer(TA_umol_kg ~ Year + Sub_region + (1 | Month), 
            data =Trends.offshore)
  summary(TA_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3370.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.6937 -0.3550  0.0732  0.5895  3.5239 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 111.4    10.56   
##  Residual             316.8    17.80   
## Number of obs: 391, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)  
## (Intercept)  2498.26924 1087.51333  366.86056   2.297   0.0222 *
## Year           -0.05908    0.53893  366.88694  -0.110   0.9128  
## Sub_regionUK    0.27805    2.86697  374.57369   0.097   0.9228  
## Sub_regionMK   -6.12303    2.83594  374.56360  -2.159   0.0315 *
## Sub_regionLK   -4.77981    2.69007  375.14829  -1.777   0.0764 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.007  0.006              
## Sub_reginMK -0.007  0.006  0.590       
## Sub_reginLK -0.014  0.012  0.624  0.632
  plot(TA_of)

  qqnorm(resid(TA_of))

  acf(resid(TA_of), main="acf(resid(TA Offshore))") 

  TA_of.emmc<-emmeans(TA_of, ~Sub_region)
        TA_of.emmc<-multcomp::cld(TA_of.emmc)
        TA_of.emmc<-TA_of.emmc[order(TA_of.emmc$Sub_region),]
  TA_of.emmc

Oceanic

hist(Trends.ocean$TA_umol_kg)

shapiro.test(Trends.ocean$TA_umol_kg)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$TA_umol_kg
## W = 0.98837, p-value = 0.2463
TA_oc_0<-lmer(TA_umol_kg ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(TA_oc_0)    
  anova(TA_oc_0)
  ranova(TA_oc_0)
  step(TA_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -557.54 1133.1                         
## (1 | SiteID)          1    8 -557.54 1131.1  0.000  1  1.0000000    
## (1 | Month)           0    7 -564.58 1143.2 14.069  1  0.0001762 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  65.27   32.63     2 133.56  0.3261 0.72234  
## Sub_region               2 323.50  161.75     2 135.60  1.6308 0.19958  
## Year                     0 409.94  409.94     1 134.74  4.0813 0.04534 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Year + (1 | Month)
TA_oc<-lmer(TA_umol_kg ~ (1 | Month), 
            data = Trends.ocean)
  summary(TA_oc)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1133
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -3.06664 -0.52823  0.09589  0.57325  2.74375 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  30.58    5.53   
##  Residual             101.45   10.07   
## Number of obs: 150, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept) 2380.456      1.812   10.623    1313   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(TA_oc)

  qqnorm(resid(TA_oc))

  acf(resid(TA_oc), main="acf(resid(TA_Ocean))")

  # TA_oc.emmc<-emmeans(TA_oc, ~Sub_region)
  #       TA_oc.emmc<-multcomp::cld(TA_oc.emmc)
  #       TA_oc.emmc<-TA_oc.emmc[order(TA_oc.emmc$Sub_region),]
  # TA_oc.emmc

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.TA_in_0 <- data.frame (anova(TA_in_0))
    av.TA_mc_0 <- data.frame (anova(TA_mc_0) )
    av.TA_of_0 <- data.frame (anova(TA_of_0))
    av.TA_oc_0 <- data.frame (anova(TA_oc_0))
    
    # Putting all into one dataframe/table
    anova_TA_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.TA_in_0, av.TA_mc_0,
                                            av.TA_of_0, av.TA_oc_0))) 
    colnames(anova_TA_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_TA_0) <- NULL
    
    # create HTML table using kableExtra
    anova_TA_0 %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "TA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "TA mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "TA offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "TA ocean", 10, 12)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
TA inshore
Year 244.12 244.12 1 335.96 0.05 0.83
Sub_region 26861.54 8953.85 3 324.67 1.71 0.17
Year:Sub_region 26923.58 8974.53 3 324.67 1.71 0.16
TA mid-channel
Year 1043.76 1043.76 1 303.96 0.54 0.46
Sub_region 6526.36 2175.45 3 296.13 1.13 0.34
Year:Sub_region 6525.95 2175.32 3 296.13 1.13 0.34
TA offshore
Year 15.13 15.13 1 366.42 0.05 0.83
Sub_region 194.42 64.81 3 371.64 0.20 0.89
Year:Sub_region 193.64 64.55 3 371.64 0.20 0.89
TA ocean
Year 406.47 406.47 1 136.76 4.06 0.05
Sub_region 64.99 32.49 2 133.54 0.32 0.72
Year:Sub_region 65.27 32.63 2 133.54 0.33 0.72
# R-ANOVAs    
    rav.TA_in_0 <- data.frame (ranova(TA_in_0))
    rav.TA_mc_0 <- data.frame (ranova(TA_mc_0) )
    rav.TA_of_0 <- data.frame (ranova(TA_of_0))
    rav.TA_oc_0 <- data.frame (ranova(TA_oc_0))
    
# Putting all into one dataframe/table
  ranova_TA_0 <- data.frame(cbind
                  (c("<none>", "(1 | Month)", "(1 | SiteID)",
                     "<none>", "(1 | Month)", "(1 | SiteID)",
                     "<none>", "(1 | Month)", "(1 | SiteID)",
                     "<none>", "(1 | Month)", "(1 | SiteID)"), 
               rbind(rav.TA_in_0, rav.TA_mc_0,
                            rav.TA_of_0, rav.TA_oc_0))) 
    colnames(ranova_TA_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_TA_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_TA_0 %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "TA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "TA mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "TA offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "TA ocean", 10, 12)
npar logLik AIC LRT DF Pr(>Chi Sq)
TA inshore
<none> 11 -1990.48 4002.97
(1 | Month) 10 -2069.77 4159.55 158.58 1 0.00
(1 | SiteID) 10 -1991.45 4002.89 1.92 1 0.17
TA mid-channel
<none> 11 -1664.40 3350.80
(1 | Month) 10 -1701.99 3423.97 75.17 1 0.00
(1 | SiteID) 10 -1665.84 3351.68 2.88 1 0.09
TA offshore
<none> 11 -1681.89 3385.78
(1 | Month) 10 -1712.85 3445.71 61.93 1 0.00
(1 | SiteID) 10 -1681.89 3383.78 0.00 1 1.00
TA ocean
<none> 9 -557.54 1133.09
(1 | Month) 8 -564.58 1145.16 14.07 1 0.00
(1 | SiteID) 8 -557.54 1131.09 0.00 1 1.00
TA_models_0<-list("Inshore" = TA_in_0, 
                   "Mid channel" = TA_mc_0, 
                   "Offshore" = TA_of_0, 
                   "Ocean" = TA_oc_0)
modelsummary(TA_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'TA model outputs (all factors)',
             coef_map=factor_order)
TA model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year −2.080 −1.670 −0.782 1.296
(4.457) (2.732) (1.101) (0.942)
Intercept 6572.526 5746.490 3957.018+ −234.002
(8992.919) (5512.076) (2222.111) (1899.673)
Upper Keys −3.961 1753.091 −1817.493
(11409.409) (7598.946) (2764.945)
Middle Keys −16949.096 −8097.847 −1984.851 402.836
(11058.674) (6722.297) (2738.961) (2186.370)
Lower Keys 4226.694 1762.679 −1551.341 1534.929
(11069.985) (6758.221) (2600.459) (2211.616)
Num.Obs. 350 321 391 150
R2 Marg. 0.147 0.070 0.025 0.060
R2 Cond. 0.556 0.398
AIC 4003.0 3350.8 3385.8 1133.1
BIC 4045.4 3392.3 3429.4 1160.2
ICC 0.5 0.4
RMSE 70.11 42.33 17.44 9.52
+ p
#modelsummary(TA_models, estimate = "p.value")

Factors removed models

TA_models<-list("Inshore" = TA_in, 
                   "Mid channel" = TA_mc, 
                   "Offshore" = TA_of, 
                   "Ocean" = TA_oc)
modelsummary(TA_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'TA model outputs (dropped facators)',
             coef_map=factor_order)
TA model outputs (dropped facators)
Inshore Mid channel Offshore Ocean
Year −0.059
(0.539)
Intercept 2375.078*** 2362.521*** 2498.269* 2380.456***
(21.652) (10.357) (1087.513) (1.812)
Upper Keys 3.191 0.278
(11.896) (2.867)
Middle Keys −32.099** −6.123*
(11.701) (2.836)
Lower Keys −94.998*** −4.780+
(11.622) (2.690)
Num.Obs. 350 321 391 150
R2 Marg. 0.141 0.000 0.018 0.000
R2 Cond. 0.539 0.376 0.273 0.232
AIC 4018.4 3384.7 3384.5 1139.0
BIC 4041.5 3399.8 3412.3 1148.0
ICC 0.5 0.4 0.3 0.2
RMSE 71.70 42.59 17.46 9.75
+ p
#modelsummary(TA_models, estimate = "p.value")

DIC-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$DIC_umol_kg
## W = 0.88724, p-value < 2.2e-16

Inshore

hist(Trends.inshore$DIC_umol_kg)

shapiro.test(Trends.inshore$DIC_umol_kg)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$DIC_umol_kg
## W = 0.99654, p-value = 0.66
# Inshore DIC
DIC_in<-lmer(DIC_umol_kg~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID),
             data=Trends.inshore)
  #summary(DIC_in)    
  anova(DIC_in)
  ranova(DIC_in)
  step(DIC_in)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1975.9 3973.8                          
## (1 | Month)           0   10 -2094.1 4208.2 236.472  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1978.0 3976.0   4.218  1    0.03999 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  25796  8598.5     3 321.52  1.6460 0.17865  
## Year                     2     67    66.8     1 334.73  0.0127 0.91027  
## Sub_region               0  94664 31554.6     3   7.15  6.0221 0.02285 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Sub_region + (1 | Month) + (1 | SiteID)
DIC_in<-lmer(DIC_umol_kg ~ Year + Sub_region +
               (1|Month) + (1|SiteID), data=Trends.inshore)
  summary(DIC_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3971.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.1985 -0.6311 -0.0178  0.5971  4.1226 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 7095.6   84.24   
##  SiteID   (Intercept)  251.2   15.85   
##  Residual             5255.8   72.50   
## Number of obs: 347, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)  1505.8479  4868.1758  334.7412   0.309   0.7573   
## Year            0.2721     2.4124  334.7290   0.113   0.9103   
## Sub_regionUK  -16.5526    18.6644    7.1543  -0.887   0.4040   
## Sub_regionMK  -45.7023    18.5361    6.9628  -2.466   0.0433 * 
## Sub_regionLK  -70.2130    18.5236    6.9438  -3.790   0.0069 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.027  0.025              
## Sub_reginMK -0.014  0.011  0.591       
## Sub_reginLK -0.026  0.024  0.590  0.596
  plot(DIC_in)

  qqnorm(resid(DIC_in))

  acf(resid(DIC_in), main="acf(resid(DIC Inshore))") 

  DIC_in.emmc<-emmeans(DIC_in, ~Sub_region+Year)
         DIC_in.emmc<-multcomp::cld(DIC_in.emmc)
         DIC_in.emmc<-DIC_in.emmc[order(DIC_in.emmc$Sub_region),]
  DIC_in.emmc

Mid channel

hist(Trends.midchanel$DIC_umol_kg)

shapiro.test(Trends.midchanel$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$DIC_umol_kg
## W = 0.93309, p-value = 8.64e-11
DIC_mc<-lmer(DIC_umol_kg~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)
  #summary(DIC_mc)    
  anova(DIC_mc)
  ranova(DIC_mc)
  step(DIC_mc)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1662.8 3347.5                          
## (1 | SiteID)          1   10 -1663.5 3346.9   1.402  1     0.2363    
## (1 | Month)           0    9 -1728.8 3475.7 130.735  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  8960.2  2986.7     3 299.85  1.4641 0.224389   
## Year                     2  2124.8  2124.8     1 313.93  1.0364 0.309433   
## Sub_region               0 29902.5  9967.5     3 304.07  4.8510 0.002598 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Sub_region + (1 | Month)
DIC_mc<-lmer(DIC_umol_kg ~ Year + Sub_region + (1 | Month), 
             data = Trends.midchanel)
  summary(DIC_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3343.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.3732 -0.4413  0.0604  0.5350  3.9154 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1700     41.23   
##  Residual             2050     45.28   
## Number of obs: 319, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  5223.535   3120.132  313.931   1.674 0.095099 .  
## Year           -1.574      1.546  313.932  -1.018 0.309433    
## Sub_regionUK   -8.601      8.196  302.877  -1.049 0.294825    
## Sub_regionMK  -21.738      7.268  302.850  -2.991 0.003011 ** 
## Sub_regionLK  -24.593      7.256  302.976  -3.389 0.000793 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.020  0.018              
## Sub_reginMK -0.004  0.003  0.530       
## Sub_reginLK -0.026  0.024  0.533  0.602
  plot(DIC_mc)

  qqnorm(resid(DIC_mc))

  acf(resid(DIC_mc), main="acf(resid(DIC Mid Channel))") 

  DIC_mc.emmc<-emmeans(DIC_mc, ~Sub_region+Year)
         DIC_mc.emmc<-multcomp::cld(DIC_mc.emmc)
         DIC_mc.emmc<-DIC_mc.emmc[order(DIC_mc.emmc$Sub_region),]
  DIC_mc.emmc

Offshore

hist(Trends.offshore$DIC_umol_kg)

shapiro.test(Trends.offshore$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$DIC_umol_kg
## W = 0.92737, p-value = 8.011e-13
DIC_of<-lmer(DIC_umol_kg~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(DIC_of)    
  anova(DIC_of)
  ranova(DIC_of)
  step(DIC_of)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1695.8 3413.7                         
## (1 | SiteID)          1   10 -1695.8 3411.7   0.00  1          1    
## (1 | Month)           0    9 -1757.9 3533.8 124.11  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  878.8  292.95     3 370.59  0.8509 0.466791   
## Year                     2  406.7  406.66     1 384.15  1.1825 0.277525   
## Sub_region               0 4526.5 1508.84     3 374.98  4.3971 0.004676 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Sub_region + (1 | Month)
DIC_of<-lmer(DIC_umol_kg ~ Year + Sub_region + (1 | Month),
             data =Trends.offshore)
  summary(DIC_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3400.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.8843 -0.4329  0.1397  0.6130  2.4102 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 243.8    15.61   
##  Residual             343.9    18.54   
## Number of obs: 390, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)   792.3190  1154.5069  384.1392   0.686  0.49295   
## Year            0.6221     0.5721  384.1451   1.087  0.27753   
## Sub_regionUK   -2.9722     2.9870  373.5600  -0.995  0.32037   
## Sub_regionMK   -9.1133     2.9547  373.5576  -3.084  0.00219 **
## Sub_regionLK   -1.3305     2.8028  373.7602  -0.475  0.63528   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.007  0.006              
## Sub_reginMK -0.007  0.005  0.590       
## Sub_reginLK -0.020  0.019  0.624  0.632
  plot(DIC_of)

  qqnorm(resid(DIC_of))

  acf(resid(DIC_of), main="acf(resid(DIC Offshore))") 

  DIC_of.emmc<-emmeans(DIC_of, ~Sub_region+Year)
         DIC_of.emmc<-multcomp::cld(DIC_of.emmc)
         DIC_of.emmc<-DIC_of.emmc[order(DIC_of.emmc$Sub_region),]
  DIC_of.emmc

Oceanic

hist(Trends.ocean$DIC_umol_kg)

shapiro.test(Trends.ocean$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$DIC_umol_kg
## W = 0.92806, p-value = 8.447e-07
DIC_oc<-lmer(DIC_umol_kg ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(DIC_oc)    
  anova(DIC_oc)
  ranova(DIC_oc)
  step(DIC_oc)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC   LRT Df Pr(>Chisq)    
## <none>                     9 -602.93 1223.8                        
## (1 | SiteID)          1    8 -602.93 1221.8  0.00  1          1    
## (1 | Month)           0    7 -620.68 1255.4 35.51  1  2.537e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  603.06  301.53     2 129.48  1.5503 0.216094   
## Sub_region               2  283.86  141.93     2 131.53  0.7231 0.487149   
## Year                     0 2034.28 2034.28     1 145.68 10.4027 0.001554 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + (1 | Month)
DIC_oc<-lmer(DIC_umol_kg ~ Year+ (1 | Month), data = Trends.ocean)
  summary(DIC_oc)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1222.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.9710 -0.4501  0.0728  0.5284  5.6177 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 181.8    13.48   
##  Residual             195.6    13.98   
## Number of obs: 148, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)   
## (Intercept) -2368.5433  1369.1200   145.6809  -1.730  0.08575 . 
## Year            2.1884     0.6785   145.6797   3.225  0.00155 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  plot(DIC_oc)

  qqnorm(resid(DIC_oc))

  acf(resid(DIC_oc), main="acf(resid(DIC open))")

  DIC_oc.emmc<-emmeans(DIC_oc, ~Year)
         DIC_oc.emmc<-multcomp::cld(DIC_oc.emmc)
         #DIC_oc.emmc<-DIC_oc.emmc[order(DIC_oc.emmc$Sub_region),]
  DIC_oc.emmc

Models summary

DIC_models<-list("Inshore" = DIC_in, 
                   "Mid channel" = DIC_mc, 
                   "Offshore" = DIC_of, 
                   "Ocean" = DIC_oc)
modelsummary(DIC_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'DIC model outputs',
             coef_map=factor_order)
DIC model outputs
Inshore Mid channel Offshore Ocean
Year 0.272 −1.574 0.622 2.188**
(2.412) (1.546) (0.572) (0.679)
Intercept 1505.848 5223.535+ 792.319 −2368.543+
(4868.176) (3120.132) (1154.507) (1369.120)
Upper Keys −16.553 −8.601 −2.972
(18.664) (8.196) (2.987)
Middle Keys −45.702* −21.738** −9.113**
(18.536) (7.268) (2.955)
Lower Keys −70.213*** −24.593*** −1.330
(18.524) (7.256) (2.803)
Num.Obs. 347 319 390 148
R2 Marg. 0.053 0.028 0.022 0.054
R2 Cond. 0.605 0.468 0.428 0.510
AIC 3987.6 3357.6 3414.6 1230.9
BIC 4018.3 3384.0 3442.4 1242.9
ICC 0.6 0.5 0.4 0.5
RMSE 70.39 44.17 18.17 13.41
+ p
#modelsummary(DIC_models, estimate = "p.value")

dTA-All

Long_plot2<- ggplot(Reef.Trends.data) +
        MyTheme +  
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank())

## 
##  Shapiro-Wilk normality test
## 
## data:  Reef.Trends.data$dTA_MY
## W = 0.81508, p-value < 2.2e-16

Inshore

# Inshore dTA
hist(Trends.inshore$dTA_MY)

shapiro.test(Trends.inshore$dTA_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$dTA_MY
## W = 0.97002, p-value = 1.519e-06
dTA_in<-lmer(dTA_MY ~ Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID),
             data=Trends.inshore)
  #summary(dTA_in)    
  anova(dTA_in)
  ranova(dTA_in)
  step(dTA_in)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1951.6 3925.2                          
## (1 | SiteID)          1   10 -1952.7 3925.3   2.072  1       0.15    
## (1 | Month)           0    9 -2032.8 4083.6 160.287  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)    
## Year:Sub_region          1  25925    8642     3 325.00  1.6620 0.1751    
## Year                     2   1403    1403     1 339.00  0.2682 0.6048    
## Sub_region               0 561528  187176     3 329.04 35.8352 <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dTA_MY ~ Sub_region + (1 | Month)
dTA_in<-lmer(dTA_MY ~ Sub_region + (1 | Month),
             data=Trends.inshore)
  summary(dTA_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dTA_MY ~ Sub_region + (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3929
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.4682 -0.5758  0.0229  0.5605  4.7357 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 4683     68.43   
##  Residual             5223     72.27   
## Number of obs: 344, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)    -4.565     21.742  14.649  -0.210  0.83660    
## Sub_regionUK    3.105     11.930 328.969   0.260  0.79483    
## Sub_regionMK  -32.734     11.676 328.953  -2.804  0.00535 ** 
## Sub_regionLK  -95.634     11.569 329.095  -8.266 3.44e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.311              
## Sub_reginMK -0.318  0.579       
## Sub_reginLK -0.322  0.582  0.599
  plot(dTA_in)

  qqnorm(resid(dTA_in))

  acf(resid(dTA_in), main="acf(resid(dTA Inshore))")

  dTA_in.emmc<-emmeans(dTA_in, ~Sub_region)
         dTA_in.emmc<-multcomp::cld(dTA_in.emmc)
         dTA_in.emmc<-dTA_in.emmc[order(dTA_in.emmc$Sub_region),]
  dTA_in.emmc

Mid channel

hist(Trends.midchanel$dTA_MY)

shapiro.test(Trends.midchanel$dTA_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$dTA_MY
## W = 0.84667, p-value < 2.2e-16
dTA_mc<-lmer(dTA_MY~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID),
             data=Trends.midchanel)
  #summary(dTA_mc)    
  anova(dTA_mc)
  ranova(dTA_mc)
  step(dTA_mc)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1634.9 3291.9                         
## (1 | Month)           0   10 -1675.6 3371.1 81.244  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1636.6 3293.2  3.278  1    0.07022 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  6569.8  2189.9     3 292.15  1.2103 0.30620  
## Year                     2  3286.6  3286.6     1 303.68  1.8119 0.17929  
## Sub_region               0 26985.2  8995.1     3   6.28  4.9261 0.04385 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dTA_MY ~ Sub_region + (1 | Month) + (1 | SiteID)
dTA_mc<-lmer(dTA_MY ~ (1 | Month) + (1|SiteID), 
             data = Trends.midchanel)
  summary(dTA_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dTA_MY ~ (1 | Month) + (1 | SiteID)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3319.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.9402 -0.4290  0.1099  0.5807  3.3885 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  889.6   29.83   
##  SiteID   (Intercept)  256.2   16.01   
##  Residual             1826.4   42.74   
## Number of obs: 317, groups:  Month, 12; SiteID, 10
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)
## (Intercept)   -17.84      10.30  15.90  -1.732    0.103
  plot(dTA_mc)

  qqnorm(resid(dTA_mc))

  acf(resid(dTA_mc), main="acf(resid(dTA Mid Channel))") 

Offshore

hist(Trends.offshore$dTA_MY)

shapiro.test(Trends.offshore$dTA_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$dTA_MY
## W = 0.82231, p-value < 2.2e-16
dTA_of<-lmer(dTA_MY~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(dTA_of)    
  anova(dTA_of)
  ranova(dTA_of)
  step(dTA_of)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1614.1 3250.2                         
## (1 | SiteID)          1   10 -1614.1 3248.2  0.000  1          1    
## (1 | Month)           0    9 -1639.0 3296.0 49.792  1   1.71e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  201.09   67.03     3 366.21  0.2673 0.84896  
## Year                     0 1155.22 1155.22     1 352.17  4.6342 0.03202 *
## Sub_region               0 2796.86  932.29     3 369.55  3.7399 0.01137 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dTA_MY ~ Year + Sub_region + (1 | Month)
dTA_of<-lmer(dTA_MY ~ Sub_region + (1 | Month), 
             data =Trends.offshore)
  summary(dTA_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dTA_MY ~ Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3239.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.6287 -0.3153  0.0989  0.5356  3.7481 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  57.45    7.579  
##  Residual             253.21   15.913  
## Number of obs: 386, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)  
## (Intercept)   -1.8304     2.9701  27.2451  -0.616   0.5428  
## Sub_regionUK   0.6779     2.5913 370.9069   0.262   0.7938  
## Sub_regionMK  -5.7041     2.5692 370.9256  -2.220   0.0270 *
## Sub_regionLK  -4.4715     2.4280 371.6279  -1.842   0.0663 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.514              
## Sub_reginMK -0.520  0.594       
## Sub_reginLK -0.551  0.629  0.637
  plot(dTA_of)

  qqnorm(resid(dTA_of))

  acf(resid(dTA_of), main="acf(resid(dTA Offshore))") 

  dTA_of.emmc<-emmeans(dTA_of, ~Sub_region)
         dTA_of.emmc<-multcomp::cld(dTA_of.emmc)
         dTA_of.emmc<-dTA_of.emmc[order(dTA_of.emmc$Sub_region),]
  dTA_of.emmc

Models summary

dTA_models<-list("Inshore" = dTA_in, 
                   "Mid channel" = dTA_mc, 
                   "Offshore" = dTA_of)
modelsummary(dTA_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'dTA model outputs',
             coef_map=factor_order)
dTA model outputs
Inshore Mid channel Offshore
Intercept −4.565 −17.845+ −1.830
(21.742) (10.304) (2.970)
Upper Keys 3.105 0.678
(11.930) (2.591)
Middle Keys −32.734** −5.704*
(11.676) (2.569)
Lower Keys −95.634*** −4.471+
(11.569) (2.428)
Num.Obs. 344 317 386
R2 Marg. 0.144 0.000 0.023
R2 Cond. 0.549 0.386 0.204
AIC 3941.0 3327.4 3251.1
BIC 3964.0 3342.4 3274.8
ICC 0.5 0.4 0.2
RMSE 70.73 41.47 15.63
+ p
#modelsummary(dTA_models, estimate = "p.value")

dDIC-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Reef.Trends.data$dDIC_MY
## W = 0.8734, p-value < 2.2e-16

Inshore

# Inshore dDIC
hist(Trends.inshore$dDIC_MY)

shapiro.test(Trends.inshore$dDIC_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$dDIC_MY
## W = 0.99413, p-value = 0.2125
dDIC_in<-lmer(dDIC_MY~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID), 
              data=Trends.inshore)
  #summary(dDIC_in)    
  anova(dDIC_in)
  ranova(dDIC_in)
  step(dDIC_in)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1935.0 3891.9                          
## (1 | Month)           0   10 -2046.1 4112.3 222.335  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1937.3 3894.6   4.699  1    0.03018 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  25663  8554.4     3 315.69  1.7009 0.16674  
## Year                     2   3283  3282.5     1 329.01  0.6483 0.42130  
## Sub_region               0  93964 31321.3     3   7.21  6.1908 0.02108 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Sub_region + (1 | Month) + (1 | SiteID)
dDIC_in<-lmer(dDIC_MY ~ Sub_region + (1 | Month)+ (1 | SiteID),
              data=Trends.inshore)
  summary(dDIC_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dDIC_MY ~ Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 3894
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.1776 -0.6750  0.0123  0.6505  4.0667 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6259.2   79.11   
##  SiteID   (Intercept)  260.7   16.15   
##  Residual             5059.3   71.13   
## Number of obs: 341, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##              Estimate Std. Error      df t value Pr(>|t|)   
## (Intercept)     8.522     27.054  16.492   0.315  0.75672   
## Sub_regionUK  -16.218     18.850   7.274  -0.860  0.41705   
## Sub_regionMK  -46.201     18.691   7.036  -2.472  0.04255 * 
## Sub_regionLK  -71.441     18.659   6.986  -3.829  0.00649 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.409              
## Sub_reginMK -0.413  0.592       
## Sub_reginLK -0.413  0.592  0.598
  plot(dDIC_in)

  qqnorm(resid(dDIC_in))

  acf(resid(dDIC_in), main="acf(resid(dDIC Inshore))") 

  dDIC_in.emmc<-emmeans(dDIC_in, ~Sub_region)
         dDIC_in.emmc<-multcomp::cld(dDIC_in.emmc)
         dDIC_in.emmc<-dDIC_in.emmc[order(dDIC_in.emmc$Sub_region),]
  dDIC_in.emmc

Mid channel

hist(Trends.midchanel$dDIC_MY)

shapiro.test(Trends.midchanel$dDIC_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$dDIC_MY
## W = 0.90416, p-value = 3.03e-13
dDIC_mc<-lmer(dDIC_MY~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)
  #summary(dDIC_mc)    
  anova(dDIC_mc)
  ranova(dDIC_mc)
  step(dDIC_mc)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1629.6 3281.1                          
## (1 | SiteID)          1   10 -1630.5 3281.0   1.855  1     0.1732    
## (1 | Month)           0    9 -1687.7 3393.4 114.405  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1   9224  3074.6     3 296.19  1.6154 0.185850   
## Year                     0  12325 12324.9     1 308.75  6.4331 0.011694 * 
## Sub_region               0  31760 10586.6     3 299.28  5.5258 0.001051 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Year + Sub_region + (1 | Month)
dDIC_mc<-lmer(dDIC_MY ~ Sub_region + (1 | Month),
              data = Trends.midchanel)
  summary(dDIC_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dDIC_MY ~ Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3286.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.3657 -0.4740  0.0462  0.5774  3.8614 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1133     33.67   
##  Residual             1955     44.22   
## Number of obs: 315, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)    0.6643    11.2377  17.2116   0.059 0.953544    
## Sub_regionUK  -9.9279     8.0964 300.2499  -1.226 0.221076    
## Sub_regionMK -22.7237     7.1784 300.2235  -3.166 0.001707 ** 
## Sub_regionLK -25.5581     7.1469 300.3309  -3.576 0.000406 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.341              
## Sub_reginMK -0.387  0.534       
## Sub_reginLK -0.388  0.537  0.608
  plot(dDIC_mc) 

  qqnorm(resid(dDIC_mc))

  acf(resid(dDIC_mc), main="acf(resid(dDIC Mid Channel))") 

  dDIC_mc.emmc<-emmeans(dDIC_mc, ~Sub_region)
         dDIC_mc.emmc<-multcomp::cld(dDIC_mc.emmc)
         dDIC_mc.emmc<-dDIC_mc.emmc[order(dDIC_mc.emmc$Sub_region),]
  dDIC_mc.emmc

Offshore

hist(Trends.offshore$dDIC_MY)

shapiro.test(Trends.offshore$dDIC_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$dDIC_MY
## W = 0.79373, p-value < 2.2e-16
dDIC_of<-lmer(dDIC_MY~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(dDIC_of)    
  anova(dDIC_of)
  ranova(dDIC_of)
  step(dDIC_of)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1604.0 3230.1                         
## (1 | SiteID)          1   10 -1604.0 3228.1  0.000  1          1    
## (1 | Month)           0    9 -1619.4 3256.8 30.659  1  3.076e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1  981.6  327.21     3 366.36  1.3246 0.2660682    
## Year                     0 2822.4 2822.40     1 297.58 11.3951 0.0008342 ***
## Sub_region               0 3746.4 1248.80     3 369.70  5.0419 0.0019546 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Year + Sub_region + (1 | Month)
dDIC_of<-lmer(dDIC_MY ~ Year+ Sub_region + (1 | Month), 
              data =Trends.offshore)
  summary(dDIC_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dDIC_MY ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3217.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -6.1598 -0.3321  0.1429  0.5680  3.7397 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  38.55    6.209  
##  Residual             247.69   15.738  
## Number of obs: 385, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)  3154.4511   934.3978  297.5305   3.376 0.000833 ***
## Year           -1.5631     0.4631  297.5800  -3.376 0.000834 ***
## Sub_regionUK   -2.7575     2.5629  369.2796  -1.076 0.282660    
## Sub_regionMK   -8.6040     2.5410  369.3161  -3.386 0.000785 ***
## Sub_regionLK   -1.7258     2.4011  369.9717  -0.719 0.472754    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.008  0.006              
## Sub_reginMK -0.007  0.005  0.594       
## Sub_reginLK -0.019  0.018  0.630  0.636
  plot(dDIC_of)

  qqnorm(resid(dDIC_of))

  acf(resid(dDIC_of), main="acf(resid(dDIC Offshore))") 

  dDIC_of.emmc<-emmeans(dDIC_of, ~Sub_region+Year)
         dDIC_of.emmc<-multcomp::cld(dDIC_of.emmc)
         dDIC_of.emmc<-dDIC_of.emmc[order(dDIC_of.emmc$Sub_region),]
  dDIC_of.emmc

Models summary

dDIC_models<-list("Inshore" = dDIC_in, 
                   "Mid channel" = dDIC_mc, 
                   "Offshore" = dDIC_of)
modelsummary(dDIC_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'dDIC model outputs',
             coef_map=factor_order)
dDIC model outputs
Inshore Mid channel Offshore
Year −1.563***
(0.463)
Intercept 8.522 0.664 3154.451***
(27.054) (11.238) (934.398)
Upper Keys −16.218 −9.928 −2.757
(18.850) (8.096) (2.563)
Middle Keys −46.201* −22.724** −8.604***
(18.691) (7.178) (2.541)
Lower Keys −71.441*** −25.558*** −1.726
(18.659) (7.147) (2.401)
Num.Obs. 341 315 385
R2 Marg. 0.059 0.031 0.067
R2 Cond. 0.589 0.387 0.193
AIC 3908.0 3298.9 3231.5
BIC 3934.8 3321.4 3259.1
ICC 0.6 0.4 0.1
RMSE 69.12 43.21 15.45
+ p
#modelsummary(dDIC_models, estimate = "p.value")

7. PCA

#str(Month_Stats)
PCA_variables<-c("DIC_mean", "TA_mean", "pCO2_mean", "Ara_mean",
              "pH_mean", "Tem_mean","Sal_mean", "Season",
              "Zone", "Sub_region", "Month2")

PCA.data<-select(Month_Stats, PCA_variables)

Name<-paste(Month_Stats$Zone, Month_Stats$Sub_region, 
            Month_Stats$Month, sep = "_")
rownames(PCA.data) <- (Name)
PCA_var.names<-c("DIC", "TA", "pCO2", "Ara",
              "pH", "Temp","Sal", "Season",
              "Zone", "Sub_region", "Month")
colnames(PCA.data) <- (PCA_var.names)
#ggpairs(PCA.data)
head(PCA.data)
library(vegan)
#library(autoplot)
library(ggfortify)

CC.rda1 <- rda(PCA.data[, -(6:11)], scale=TRUE)
CC.rda2 <- prcomp(PCA.data[, -(6:11)], scale=TRUE)
summary(CC.rda1)
## 
## Call:
## rda(X = PCA.data[, -(6:11)], scale = TRUE) 
## 
## Partitioning of correlations:
##               Inertia Proportion
## Total               5          1
## Unconstrained       5          1
## 
## Eigenvalues, and their contribution to the correlations 
## 
## Importance of components:
##                        PC1    PC2     PC3      PC4       PC5
## Eigenvalue            2.55 1.9602 0.47883 0.008886 0.0019029
## Proportion Explained  0.51 0.3920 0.09577 0.001777 0.0003806
## Cumulative Proportion 0.51 0.9021 0.99784 0.999619 1.0000000
## 
## Scaling 2 for species and site scores
## * Species are scaled proportional to eigenvalues
## * Sites are unscaled: weighted dispersion equal on all dimensions
## * General scaling constant of scores:  5.469602 
## 
## 
## Species scores
## 
##           PC1     PC2      PC3       PC4      PC5
## DIC  -0.05552  2.4431 -0.07537 -0.007863  0.07452
## TA    1.07169  2.1249 -0.56043  0.029789 -0.06861
## pCO2 -2.34755  0.2331 -0.62637 -0.159397 -0.01484
## Ara   1.74079 -1.0840 -1.33302 -0.012281  0.02983
## pH    2.35909  0.1240  0.61315 -0.163273 -0.00386
## 
## 
## Site scores (weighted sums of species scores)
## 
##                          PC1        PC2       PC3       PC4       PC5
## Inshore_BB_Jan     -0.080069  0.7539854  0.456391  0.092977  0.159036
## Inshore_BB_Feb      0.417307  0.4512656  0.364161 -0.210958  0.215637
## Inshore_BB_Mar      0.492968  0.3248128  0.043874 -0.280525  0.024573
## Inshore_BB_Apr      0.717303 -0.5103336  0.087995 -0.541087 -0.282290
## Inshore_BB_May      0.647383 -0.3846725 -0.151919 -0.447432 -0.132122
## Inshore_BB_Jun     -0.029219 -0.8499796  0.479656  0.392550  0.150100
## Inshore_BB_Jul     -0.504001 -0.3190959 -0.177733  0.234274 -0.382684
## Inshore_BB_Aug     -0.497922 -0.2070975 -0.503920 -0.557451 -0.391026
## Inshore_BB_Sep     -1.086319  0.3547316 -0.344368 -1.669542 -0.412421
## Inshore_BB_Oct     -1.098578  0.7012590 -0.366387 -1.447755 -0.606811
## Inshore_BB_Nov     -0.372862  0.6687206 -0.037990 -0.100462 -0.194547
## Inshore_BB_Dec     -0.119021  0.6404513  0.375628  0.091136  0.167365
## Inshore_UK_Jan      0.124641  0.8896160  0.342349 -0.102604  0.050070
## Inshore_UK_Feb      0.680088  0.1397443  0.345466 -0.614502  0.066163
## Inshore_UK_Mar      0.610439  0.1660965  0.001473 -0.372967 -0.345958
## Inshore_UK_Apr      1.216231 -1.0742692 -0.066480 -1.800223 -0.705026
## Inshore_UK_May      0.996427 -0.9178564 -0.114166 -0.998742 -0.590887
## Inshore_UK_Jun      0.295848 -0.5107352 -0.155382  0.232370  0.005968
## Inshore_UK_Jul     -0.210552 -0.2751376 -0.471386  0.178738 -0.125705
## Inshore_UK_Aug      0.142293 -0.3725017 -0.802168  0.283018  0.009227
## Inshore_UK_Sep     -0.924098 -0.0699711 -0.447643 -0.888534 -0.252864
## Inshore_UK_Oct     -1.045798  0.5023971 -0.315999 -1.396787 -0.551630
## Inshore_UK_Nov     -0.769913  1.0353953 -0.219340 -1.035345 -0.912475
## Inshore_UK_Dec     -0.145236  0.9323143  0.114997 -0.049600 -0.233427
## Inshore_MK_Jan      0.056671  1.1595207  0.037518  0.001205 -0.132359
## Inshore_MK_Feb      0.807850  0.4648431  0.033851 -0.980542  0.705563
## Inshore_MK_Mar      0.491864  0.2272537 -0.027678 -0.171228 -0.400813
## Inshore_MK_Apr      0.940584 -0.6868600 -0.061836 -1.023662 -0.538141
## Inshore_MK_May      0.947519 -1.0268837  0.013390 -1.046979 -0.698433
## Inshore_MK_Jun      0.160732 -1.0590595  0.306574  0.116315 -0.047826
## Inshore_MK_Jul     -0.683490 -1.2434164  0.744609  0.716768 -0.653362
## Inshore_MK_Aug     -0.321595 -0.8943156  0.265868  0.608883 -0.019540
## Inshore_MK_Sep     -0.888855 -0.8852520  0.380960  0.274261 -0.419462
## Inshore_MK_Oct     -0.556382  0.1184323 -0.097186 -0.551056  0.287254
## Inshore_MK_Nov     -0.275140  0.1491419  0.184164  0.208480 -0.164513
## Inshore_MK_Dec     -0.061125  0.8554369  0.225455 -0.027144  0.036211
## Inshore_LK_Jan     -0.564659  0.5926086  0.963478  0.171954 -0.216286
## Inshore_LK_Feb      0.267351  0.5358781  0.380421 -0.159304  0.380583
## Inshore_LK_Mar      0.440663  0.0346635  0.267776 -0.332876 -0.190229
## Inshore_LK_Apr      0.378949 -0.7642832  0.585728 -0.246506  0.161826
## Inshore_LK_May      0.213205 -1.2463711  1.107684  0.095769 -0.034456
## Inshore_LK_Jun     -0.299728 -0.9063526  0.600088  0.381431 -0.139592
## Inshore_LK_Jul     -1.171787 -0.8595304  0.746376  0.117162 -0.625488
## Inshore_LK_Aug     -1.414780 -1.0262726  0.793940 -1.631919  3.073166
## Inshore_LK_Sep     -1.308589 -0.7902957  0.637666 -0.438920 -0.438266
## Inshore_LK_Oct     -0.968443 -0.2850522  0.649046 -0.314838  0.008713
## Inshore_LK_Nov     -0.881095  0.2884499  0.442489 -0.022094 -0.815052
## Inshore_LK_Dec     -0.324311  0.1676589  1.000853  0.288712  0.202920
## Mid channel_BB_Jan  0.081080  0.2686107  0.419206  0.200639  0.051901
## Mid channel_BB_Feb  0.172030  0.2762156  0.501836  0.098141  0.173454
## Mid channel_BB_Mar  0.297450  0.1910812  0.270365  0.089281 -0.114827
## Mid channel_BB_Apr  0.346015 -0.0659565  0.100144  0.036608 -0.119536
## Mid channel_BB_May  0.328616  0.0360189 -0.132946  0.118926 -0.106348
## Mid channel_BB_Jun  0.031238 -0.1684818 -0.151700  0.248731  0.177683
## Mid channel_BB_Jul -0.193232  0.0008191 -0.532947  0.188811 -0.123082
## Mid channel_BB_Aug -0.261570 -0.1024514 -0.574914  0.211539 -0.200440
## Mid channel_BB_Sep -0.531528  0.0445564 -0.251237 -0.225172  0.238720
## Mid channel_BB_Oct -0.344148  0.1881645 -0.303637 -0.085824  0.175603
## Mid channel_BB_Nov -0.088935  0.1948601  0.035985  0.169334 -0.146176
## Mid channel_BB_Dec -0.005996  0.3620453  0.289420  0.185511  0.038331
## Mid channel_UK_Jan  0.226642  0.3290768  0.338663  0.054950  0.128544
## Mid channel_UK_Feb  0.352518  0.1527601  0.526416 -0.125459  0.287610
## Mid channel_UK_Mar  0.442570 -0.0150254  0.245445 -0.172447 -0.123566
## Mid channel_UK_Apr  0.733488 -0.1822489 -0.176963 -0.978369  0.786551
## Mid channel_UK_May  0.680829 -0.1604492 -0.350116 -0.412290 -0.362833
## Mid channel_UK_Jun  0.124555 -0.0829247 -0.405799  0.249648 -0.074828
## Mid channel_UK_Jul -0.159177 -0.0788420 -0.537187  0.185357  0.033849
## Mid channel_UK_Aug  0.117709  0.0100999 -0.936753  0.245747 -0.065856
## Mid channel_UK_Sep -0.103033 -0.1873534 -0.672088  0.078761  0.538251
## Mid channel_UK_Oct -0.328536  0.1444733 -0.364662 -0.126435  0.333851
## Mid channel_UK_Nov -0.196957  0.0529116  0.183926  0.201945  0.140793
## Mid channel_UK_Dec  0.046917  0.3443033  0.267758  0.202378 -0.021879
## Mid channel_MK_Jan  0.024115  0.6111878  0.206298  0.134615 -0.109445
## Mid channel_MK_Feb  0.378998  0.2072672  0.438841 -0.149551  0.235686
## Mid channel_MK_Mar  0.449242  0.1527225  0.168722 -0.218612 -0.280383
## Mid channel_MK_Apr  0.590716 -0.1395414 -0.147408 -0.201610 -0.212645
## Mid channel_MK_May  0.580328 -0.4817111 -0.087733 -0.325459 -0.343832
## Mid channel_MK_Jun  0.017045 -0.5683920  0.019343  0.363207  0.069526
## Mid channel_MK_Jul -0.371417 -0.5815118 -0.070043  0.452588 -0.093172
## Mid channel_MK_Aug -0.023282 -0.4187343 -0.444991  0.397030  0.093777
## Mid channel_MK_Sep -0.659454 -0.4936600  0.051944  0.103974  0.162873
## Mid channel_MK_Oct -0.156086  0.0993805 -0.377652 -0.023100  0.414989
## Mid channel_MK_Nov -0.067639  0.0238673  0.086653  0.224022  0.090274
## Mid channel_MK_Dec -0.020845  0.4700438  0.306279  0.108841  0.013854
## Mid channel_LK_Jan -0.360370  0.4936598  0.687886  0.144566  0.040060
## Mid channel_LK_Feb  0.288601  0.4807089  0.300610 -0.118979  0.180225
## Mid channel_LK_Mar  0.221424  0.2439356  0.203512  0.075293 -0.043652
## Mid channel_LK_Apr  0.146310 -0.1484986  0.161059 -0.236676 -0.192959
## Mid channel_LK_May  0.208481 -0.6734195  0.614467  0.219229 -0.088080
## Mid channel_LK_Jun -0.077433 -0.2935608 -0.032655  0.322784 -0.072121
## Mid channel_LK_Jul -0.395927 -0.2723662 -0.282504  0.231468 -0.240295
## Mid channel_LK_Aug -0.386762 -0.5245157 -0.034230  0.482337 -1.948842
## Mid channel_LK_Sep -0.605622 -0.5893130  0.157691  0.182188  0.302359
## Mid channel_LK_Oct -0.271153  0.0164411 -0.218705  0.050044  0.303262
## Mid channel_LK_Nov -0.206202  0.0596093  0.118979  0.210486 -0.106739
## Mid channel_LK_Dec  0.016178  0.2075496  0.392785  0.188980  0.073025
## Offshore_BB_Jan     0.123896  0.1796639  0.263640  0.131838  0.217052
## Offshore_BB_Feb     0.267615  0.1091596  0.529314  0.004660  0.214283
## Offshore_BB_Mar     0.280004  0.1430616  0.267855  0.102249 -0.121700
## Offshore_BB_Apr     0.081134  0.1632253  0.094879  0.236322 -0.122974
## Offshore_BB_May     0.188581  0.1023062 -0.076094  0.164471  0.004170
## Offshore_BB_Jun    -0.149182  0.0742131 -0.244706  0.196786 -0.139650
## Offshore_BB_Jul    -0.096466  0.0149908 -0.588901  0.152181  0.084406
## Offshore_BB_Aug    -0.386330 -0.0023998 -0.548027  0.073485 -0.355059
## Offshore_BB_Sep    -0.196291 -0.0434459 -0.578138 -0.232204  0.443955
## Offshore_BB_Oct    -0.083439  0.0213190 -0.376053  0.056808  0.452259
## Offshore_BB_Nov     0.108313  0.0377352 -0.078493  0.253121 -0.122264
## Offshore_BB_Dec     0.050673  0.2043999  0.196412  0.167071  0.044340
## Offshore_UK_Jan     0.153231  0.1895434  0.277973  0.179573  0.031052
## Offshore_UK_Feb     0.252026  0.1914798  0.594766 -0.031192  0.325287
## Offshore_UK_Mar     0.235913  0.1557187  0.237807  0.161064 -0.115577
## Offshore_UK_Apr     0.101747  0.1405046  0.114217  0.204263 -0.081670
## Offshore_UK_May     0.148670  0.1588312 -0.126341  0.227157 -0.186724
## Offshore_UK_Jun    -0.055031  0.0344786 -0.297952  0.266646 -0.151867
## Offshore_UK_Jul    -0.146794 -0.0691797 -0.546540  0.207404 -0.022434
## Offshore_UK_Aug     0.040746  0.0088196 -0.829930  0.255412 -0.110743
## Offshore_UK_Sep    -0.026777 -0.1877966 -0.674391  0.089980  0.507719
## Offshore_UK_Oct     0.013585  0.0094032 -0.385492  0.069518  0.512075
## Offshore_UK_Nov    -0.033260 -0.0170553  0.033489  0.286272  0.064600
## Offshore_UK_Dec     0.036311  0.2651256  0.161379  0.185996 -0.031561
## Offshore_MK_Jan     0.063649  0.2428240  0.311331  0.223912  0.019689
## Offshore_MK_Feb     0.265526  0.2110340  0.650496 -0.060106  0.346261
## Offshore_MK_Mar     0.207268  0.1858139  0.244845  0.180470 -0.146356
## Offshore_MK_Apr     0.218314  0.0789399  0.072401  0.155750 -0.098735
## Offshore_MK_May     0.123729  0.1077204 -0.090528  0.209279 -0.177057
## Offshore_MK_Jun     0.094489 -0.1525861 -0.227734  0.273361  0.025093
## Offshore_MK_Jul    -0.193138 -0.2286722 -0.352228  0.238943  0.098318
## Offshore_MK_Aug     0.021478 -0.0767230 -0.693046  0.254532  0.020091
## Offshore_MK_Sep    -0.117051 -0.3212203 -0.364855  0.194320  0.513333
## Offshore_MK_Oct    -0.014283  0.0291906 -0.422940  0.036137  0.519225
## Offshore_MK_Nov     0.175570 -0.0473526 -0.121210  0.214700  0.068938
## Offshore_MK_Dec     0.088645  0.1565409  0.252194  0.138171  0.109288
## Offshore_LK_Jan     0.058970  0.2857051  0.411977  0.228382  0.007019
## Offshore_LK_Feb     0.167616  0.2767659  0.717416 -0.015907  0.371277
## Offshore_LK_Mar     0.157992  0.1295156  0.195678  0.206924 -0.165108
## Offshore_LK_Apr    -0.031739  0.1212983  0.186456  0.209965 -0.181020
## Offshore_LK_May     0.020411  0.1114056  0.082260  0.316359 -0.200566
## Offshore_LK_Jun    -0.087593  0.0057823 -0.239096  0.288915 -0.141305
## Offshore_LK_Jul    -0.261641  0.0329310 -0.542811  0.126061 -0.199980
## Offshore_LK_Aug    -0.179853  0.0443852 -0.617626  0.172932 -0.312085
## Offshore_LK_Sep    -0.097682 -0.2162602 -0.352073  0.097404  0.608239
## Offshore_LK_Oct    -0.090081  0.0428623 -0.318595  0.115525  0.308925
## Offshore_LK_Nov     0.030796  0.0269884 -0.034803  0.288337 -0.093536
## Offshore_LK_Dec     0.122370  0.1400435  0.210843  0.078730  0.176844
## Oceanic_UK_Jan      0.127014  0.1203089  0.156126  0.192266  0.084697
## Oceanic_UK_Feb      0.269915  0.1867839  0.588315 -0.008817  0.169718
## Oceanic_UK_Mar      0.207466  0.0518943  0.284912  0.155393  0.029800
## Oceanic_UK_Apr      0.237694  0.0749999  0.199711  0.106444  0.069566
## Oceanic_UK_May      0.310533  0.1071029 -0.110880  0.168519 -0.192264
## Oceanic_UK_Jun      0.091701  0.0375338 -0.367460  0.252405 -0.097140
## Oceanic_UK_Jul     -0.024223 -0.0796508 -0.587094  0.201507  0.149123
## Oceanic_UK_Aug      0.139307  0.1326737 -0.932162  0.242891 -0.207574
## Oceanic_UK_Sep      0.140378 -0.2266276 -0.631314  0.033277  0.885965
## Oceanic_UK_Oct     -0.045900  0.0015541 -0.450922  0.060193  0.440763
## Oceanic_UK_Nov      0.044888 -0.0417239  0.051290  0.195380  0.328576
## Oceanic_UK_Dec      0.124658  0.1845401  0.074372  0.158960 -0.060913
## Oceanic_MK_Jan      0.133419  0.1804947  0.259521  0.181455  0.062168
## Oceanic_MK_Feb     -0.046636  0.2930968  0.545091 -0.251298 -0.037581
## Oceanic_MK_Mar      0.128234  0.0998006  0.184472  0.248542 -0.086926
## Oceanic_MK_Apr     -0.444192  0.3161560  0.020303 -1.047040 -0.918255
## Oceanic_MK_May      0.043353  0.2063294 -0.097894  0.228583 -0.181682
## Oceanic_MK_Jun      0.061000  0.0301871 -0.376947  0.266332 -0.159031
## Oceanic_MK_Jul     -0.033099 -0.0588004 -0.580371  0.166671  0.189668
## Oceanic_MK_Aug      0.014009  0.0507476 -0.756578  0.191601  0.025759
## Oceanic_MK_Sep      0.144692 -0.1384619 -0.633486  0.082715  0.668979
## Oceanic_MK_Oct     -0.026554  0.0704968 -0.512717  0.076375  0.296927
## Oceanic_MK_Nov      0.187863 -0.0165563 -0.194944  0.264154 -0.131242
## Oceanic_MK_Dec      0.071788  0.1274158  0.229944  0.147423  0.113302
## Oceanic_LK_Jan      0.113815  0.2106856  0.321129  0.223068 -0.040646
## Oceanic_LK_Feb      0.313149  0.1972388  0.535522 -0.057188  0.147272
## Oceanic_LK_Mar      0.142936  0.0709909  0.149903  0.226718 -0.065188
## Oceanic_LK_Apr     -0.013182  0.1344065  0.143877  0.259811 -0.084268
## Oceanic_LK_May      0.040519  0.1780986 -0.002768  0.285668 -0.182649
## Oceanic_LK_Jun      0.017238  0.0612943 -0.344613  0.244930 -0.148788
## Oceanic_LK_Jul     -0.084127 -0.0466388 -0.462392  0.120568  0.370429
## Oceanic_LK_Aug     -0.073481  0.0683452 -0.703570  0.134632  0.274036
## Oceanic_LK_Sep      0.194544 -0.2000926 -0.559225 -0.006613  0.921143
## Oceanic_LK_Oct     -0.040187  0.0297304 -0.402223  0.105522  0.359109
## Oceanic_LK_Nov      0.236117 -0.0281854 -0.188360  0.198519  0.025907
## Oceanic_LK_Dec      0.112173  0.1203014  0.146707  0.086058  0.221269
# Checking if the PC axes are meaningful
eigenval <- CC.rda1$CA$eig   # Here you will get the eigenvalues
sitecoord <- CC.rda1$CA$u[,1:2]   # The site coordinates along PC1 and PC2
  eig <- data.frame(eigenval)
  eig$nb <- c(1:length(eigenval))
  eig$prop <- eig$eigenval/sum(eig$eigenval)
  eig
# (Kaiser-Guttman)
par(mfrow=c(1,2))
  barplot(eig$eigenval, main="Eigenvalues",las=2)
  abline(h=mean(eig$eigenval),col="red")    # average eigenvalue
  legend("topright","Average eigenvalue",lwd=1,col=2,bty="n")
  
  barplot(100*eig$prop,main="% of variance",las=2)

par(mfrow=c(1,1))

autoplot(CC.rda2, data = PCA.data, colour="Season", 
                shape="Sub_region",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_wrap(~Zone)+MyTheme+Season_colour+Season_fill

autoplot(CC.rda2, data = PCA.data, colour="Zone", 
                shape="Sub_region",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_wrap(~Season)+MyTheme

autoplot(CC.rda2, data = PCA.data, colour="Sub_region", 
                shape="Zone",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_grid(~Season)+MyTheme

autoplot(CC.rda2, data = PCA.data, colour="Season", 
                shape="Zone",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_wrap(~Sub_region)+MyTheme+Season_colour+Season_fill

Packages used

# Creates bibliography 
#knitr::write_bib(c(.packages()), "packages.bib")
Arel-Bundock, Vincent. 2022. Modelsummary: Summary Tables and Plots for Statistical Models and Data: Beautiful, Customizable, and Publication-Ready. https://vincentarelbundock.github.io/modelsummary/.
Arnold, Jeffrey B. 2021. Ggthemes: Extra Themes, Scales and Geoms for Ggplot2. https://github.com/jrnold/ggthemes.
Attali, Dean, and Christopher Baker. 2019. ggExtra: Add Marginal Histograms to Ggplot2, and More Ggplot2 Enhancements. https://github.com/daattali/ggExtra.
Auguie, Baptiste. 2017. gridExtra: Miscellaneous Functions for "Grid" Graphics. https://CRAN.R-project.org/package=gridExtra.
Bates, Douglas, Martin Mächler, Ben Bolker, and Steve Walker. 2015. “Fitting Linear Mixed-Effects Models Using lme4.” Journal of Statistical Software 67 (1): 1–48. https://doi.org/10.18637/jss.v067.i01.
Bates, Douglas, and Martin Maechler. 2021. Matrix: Sparse and Dense Matrix Classes and Methods. http://Matrix.R-forge.R-project.org/.
Bates, Douglas, Martin Maechler, Ben Bolker, and Steven Walker. 2021. Lme4: Linear Mixed-Effects Models Using Eigen and S4. https://github.com/lme4/lme4/.
Cheng, Joe, Bhaskar Karambelkar, and Yihui Xie. 2021. Leaflet: Create Interactive Web Maps with the JavaScript Leaflet Library. https://rstudio.github.io/leaflet/.
Grolemund, Garrett, and Hadley Wickham. 2011. “Dates and Times Made Easy with lubridate.” Journal of Statistical Software 40 (3): 1–25. https://www.jstatsoft.org/v40/i03/.
Henry, Lionel, and Hadley Wickham. 2020. Purrr: Functional Programming Tools. https://CRAN.R-project.org/package=purrr.
J, Lemon. 2006. “Plotrix: A Package in the Red Light District of r.” R-News 6 (4): 8–12.
Kassambara, Alboukadel. 2020. Ggpubr: Ggplot2 Based Publication Ready Plots. https://rpkgs.datanovia.com/ggpubr/.
Kuznetsova, Alexandra, Per B. Brockhoff, and Rune H. B. Christensen. 2017. lmerTest Package: Tests in Linear Mixed Effects Models.” Journal of Statistical Software 82 (13): 1–26. https://doi.org/10.18637/jss.v082.i13.
Kuznetsova, Alexandra, Per Bruun Brockhoff, and Rune Haubo Bojesen Christensen. 2019. lmerTest: Tests in Linear Mixed Effects Models. https://github.com/runehaubo/lmerTestR.
Legendre, Pierre. 2018. Lmodel2: Model II Regression. https://CRAN.R-project.org/package=lmodel2.
Lemon, Jim, Ben Bolker, Sander Oom, Eduardo Klein, Barry Rowlingson, Hadley Wickham, Anupam Tyagi, et al. 2021. Plotrix: Various Plotting Functions. https://CRAN.R-project.org/package=plotrix.
Lenth, Russell V. 2022. Emmeans: Estimated Marginal Means, Aka Least-Squares Means. https://github.com/rvlenth/emmeans.
Müller, Kirill, and Hadley Wickham. 2021. Tibble: Simple Data Frames. https://CRAN.R-project.org/package=tibble.
R Core Team. 2020. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Robinson, David, Alex Hayes, and Simon Couch. 2022. Broom: Convert Statistical Objects into Tidy Tibbles. https://CRAN.R-project.org/package=broom.
Spinu, Vitalie, Garrett Grolemund, and Hadley Wickham. 2021. Lubridate: Make Dealing with Dates a Little Easier. https://CRAN.R-project.org/package=lubridate.
Wickham, Hadley. 2007. “Reshaping Data with the reshape Package.” Journal of Statistical Software 21 (12): 1–20. http://www.jstatsoft.org/v21/i12/.
———. 2011. “The Split-Apply-Combine Strategy for Data Analysis.” Journal of Statistical Software 40 (1): 1–29. http://www.jstatsoft.org/v40/i01/.
———. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. https://ggplot2.tidyverse.org.
———. 2019. Stringr: Simple, Consistent Wrappers for Common String Operations. https://CRAN.R-project.org/package=stringr.
———. 2020a. Plyr: Tools for Splitting, Applying and Combining Data. https://CRAN.R-project.org/package=plyr.
———. 2020b. Reshape2: Flexibly Reshape Data: A Reboot of the Reshape Package. https://github.com/hadley/reshape.
———. 2021a. Forcats: Tools for Working with Categorical Variables (Factors). https://CRAN.R-project.org/package=forcats.
———. 2021b. Tidyr: Tidy Messy Data. https://CRAN.R-project.org/package=tidyr.
———. 2021c. Tidyverse: Easily Install and Load the Tidyverse. https://CRAN.R-project.org/package=tidyverse.
Wickham, Hadley, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D’Agostino McGowan, Romain François, Garrett Grolemund, et al. 2019. “Welcome to the tidyverse.” Journal of Open Source Software 4 (43): 1686. https://doi.org/10.21105/joss.01686.
Wickham, Hadley, Winston Chang, Lionel Henry, Thomas Lin Pedersen, Kohske Takahashi, Claus Wilke, Kara Woo, Hiroaki Yutani, and Dewey Dunnington. 2021. Ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics. https://CRAN.R-project.org/package=ggplot2.
Wickham, Hadley, Romain François, Lionel Henry, and Kirill Müller. 2021. Dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyr.
Wickham, Hadley, and Jim Hester. 2020. Readr: Read Rectangular Text Data. https://CRAN.R-project.org/package=readr.
Xie, Yihui. 2014. “Knitr: A Comprehensive Tool for Reproducible Research in R.” In Implementing Reproducible Computational Research, edited by Victoria Stodden, Friedrich Leisch, and Roger D. Peng. Chapman; Hall/CRC. http://www.crcpress.com/product/isbn/9781466561595.
———. 2015. Dynamic Documents with R and Knitr. 2nd ed. Boca Raton, Florida: Chapman; Hall/CRC. https://yihui.org/knitr/.
———. 2021. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.
Zhu, Hao. 2021. kableExtra: Construct Complex Table with Kable and Pipe Syntax. https://CRAN.R-project.org/package=kableExtra.